jeudi 12 février 2015

Updating SQLite Database by Copying Records from Assets to SD Card

I have a SQLite database which is frequently updated. The database is copied from the project's assets directory once after being installed to a device, and subsequent updates are done using the ContentValues and db.update commands, like so:



cv = new ContentValues();
cv.put(AssetDatabaseHelper.KEY_1, "updated text");
where = AssetDatabaseHelper.KEY_ID + "=?";
whereArgs = new String[]{String.valueOf(330)};
db.update(AssetDatabaseHelper.TABLE_NAME, cv, where, whereArgs);


I also update the original database in the assets folder, so new installers will have the latest changes as well. This dual maintenance of any changes made to the database is becoming quite a chore.


Rather than doing a cv.put for each column of a record that was changed and updating it that way, is there a command which simply copies a specified record from the 'assets' database to the local SD card copy? Something that would allow me to replace the multiple lines of code to do a ContentValues update with a single 'copy entire record'?


Aucun commentaire:

Enregistrer un commentaire