Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Synchronize SQLite database and Dropbox datastore

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!

like image 346
Ilia Kopylov Avatar asked Apr 07 '14 13:04

Ilia Kopylov


2 Answers

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.

like image 136
user94559 Avatar answered Oct 16 '22 23:10

user94559


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.

like image 40
Ilia Kopylov Avatar answered Oct 17 '22 01:10

Ilia Kopylov