views:

140

answers:

1

I export my application to .apk file, sign it then install it. But when I run my App, it displays an error because there's no data in my database. The database was created as a new one when I installed the application, so all the data were lost! How can I include database data when exporting an Android application?

+4  A: 

Option #1: Package the database as a raw resource or asset, and use streams to copy that database to its proper position when the app is first run.

Option #2: Package SQL statements to populate the database as a raw resource, and execute those statements in your SQLiteOpenHelper's onCreate() method.

Option #3: Put the smarts straight in your Java code to populate your database in your SQLiteOpenHelper's onCreate() method.

Option #4: Download the database on first run and copy it to its proper position.

And so on.

CommonsWare