I develop notepad application for Android. App stores it's data in SQLite database. I want to implement optional backup/sync for app data using Dropbox datastore API. If user has linked his Dropbox account app data should be stored in Dropbox cloud and synced between all user's devices.
My solution is initially store all app data in database. When user has linked his Dropbox account application will move all data to datastore. After that app will work with datastore (because it supports offline caching and performes synchronization in background). If user has deciced to unlink his Dropbox account from app all his data will be moved back to local SQLite database on device. I want to create interface to app data storage and have two implementations: SQLite database and Dropbox datastore. So other app components won't be dependent of storage implementation. And of course all these will be completely transparent to user.
Is it a good approach? Can you please suggest the better way?
Thanks in advance!
FYI, the Datastore API 3.0 beta includes a preview feature called "local datastores" that will hopefully obviate the need for this. See the blog post here announcing the preview feature: https://www.dropbox.com/developers/blog/97/sync-api-and-datastore-api-30-beta-release.
Finally I have this implemented. Sources can be found here. Key class is implementation of Dropbox storage. App uses storage interface and works fine with both implementations (database and Dropbox datastore). Both implementations cache results of frequent queries. Only one thing I concerned about is performance. I haven't yet tested and compared performance of data queries and storage content modification calls for these implementations. But I would say that app works smoothly and I haven't noticed any lags.
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