jeudi 5 février 2015

Backup Sqlite objects in Android

I am about to implement backup for my Android app, and my issue is: The data resides in an sqlite db. Some of the data are just there for user convenience, and can be recreated from other sources. So in order to minimize the size, I wish to export relevant data only (the limit for backup using the Google API is 1mb).


All the data has class equivalents, which are populated via my SQLiteOpenHelper implementation. This means I can implement serialization.


So far I can see the following options:



  • Serialization using Java Serializable, and write all objects into a binary chunk and pass it to writeEntityData()

  • Serialization using XML or JSON, perhaps together with the zip API and dump the file as a binary chunk

  • Clone the database with relevant objects only. Probably a lot of work.


So far, using XML or JSON seems to be the best option, as I can reuse that for data sharing across users/devices. Java Serializable seems to bloat the size..


Would like to hear your opinions on this !


Aucun commentaire:

Enregistrer un commentaire