I have basically finished developing an android app that makes use of SQLite databases that I copy to the user data area on the device eg /data/data/com.company.app/databases/users.db
I am unsure how the marketplace app update procedure takes place and am also unsure as to how I could test it.
I currently check whether the database exists on the device and copy it if it doesn't (generally only occurs on first ever launch). What happens if I have a new version of the database in my updated app? Will an marketplace update wipe user data so that it will copy my new database in on next launch?
What happens in the future if I make database changes/add records/etc and package this with the new app? Will this database not overwrite the old database?
Otherwise, to avoid copying and overriding the databases from the app bundle on every launch is there a way to check the size and date of the database files and only copy if the database in the bundle is newer?
If anyone needs clarification please ask.
At the top right, tap the profile icon. Tap Manage apps & device. Apps with an update available are labeled "Update available." Tap Update.
Due to its inclusion in the Android Software Development Kit (SDK), SQLite, an open-source relational database, is the most common database technology associated with Android applications.
But by default all the android application store database on internal storage path /data/data/<application_package_name>/databases . And its applicable for all devices rooted or un-rooted.
The developer publishes a new version (4.0). The 90-day period ends, the app is added to the update queue and will be automatically updated according to the default update behavior, once the constraints are met. The constraints are met and therefore the app is updated to the latest available version (4.0).
I am doing something similar. What I did is set the database version, and then when I check if the database exists, I also to make sure it's the correct version. If it's not, I save user favorites from the database, wipe and recopy my db, and then put back user favorites.
This is my on upgrade
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion == 2) {
System.out.println("Performing upgrade!");
openDataBase();
// save the old favorites
Cursor mCursor = getFavorites();
ArrayList<Stop> favs = allCursorToStops(mCursor);
mCursor.close();
deleteRecreate(db);
openDataBase();
for (int i = 0; i < favs.size(); i++)
setFavorite(favs.get(i));
close();
} else {
deleteRecreate(db);
}
}
Here is where I check existence/if need to upgrade etc
boolean dbExist = checkDataBase();
if(dbExist){
// check if we need to upgrade
openDataBase();
int cVersion = myDataBase.getVersion();
close();
if(cVersion != VERSION)
onUpgrade(myDataBase, myDataBase.getVersion(), VERSION);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With