Include database data when exporting Android app
I export my app to an .apk file, sign it and install it. But when I run my application, it displays an error because there is no data in my database.
The database was created as new when I installed the app, so all data was lost!
How do I include database data when exporting an Android app?
source to share
Option # 1: Package the database as a raw resource or asset and use streams to copy that database to the desired location the first time you run the application.
Option # 2: SQL package statements to populate the database as a raw resource and execute those statements in your method SQLiteOpenHelper
onCreate()
.
Option # 3: Put emoticons directly in Java code to populate the database in your method SQLiteOpenHelper
onCreate()
.
Option # 4: Load the database on first launch and copy it to the desired location.
Etc.
source to share