Question

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!

Was it helpful?

Solution 2

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top