2 . Add the following statements in bold to the MainActivity.java fi le: public void onCreate(Bundle savedInstanceState)

Question:

2 . Add the following statements in bold to the MainActivity.java fi le:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
String destPath = “/data/data/” + getPackageName() +
“/databases/MyDB”;
File f = new File(destPath);
if (!f.exists()) {
CopyDB( getBaseContext().getAssets().open(“mydb”), new FileOutputStream(destPath));
}
} catch (FileNotFoundException

e) {
e.printStackTrace();
} catch (IOException

e) {
e.printStackTrace();
}
DBAdapter db = new DBAdapter(this);
//---get all contacts---
db.open();
Cursor c = db.getAllContacts();
if (c.moveToFirst())
{
do {
DisplayContact(c);
} while (c.moveToNext());
}
db.close();

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: