First off, this is not a duplicate of any of these questions, which discuss using a single Dropbox account as the backend of a multi-user app
I have built a handful of apps, mostly on Windows Phone and Windows Store, and have lots more in the works.
I often find myself wanting to add data synching to these apps, between devices but for the same user. My apps are often free or very cheap, and I can't afford to fork out money for a database hosting server. I do have a paid hosting account with some limited DB space I could use, but in the (unlikely) event that one of my apps becomes a runaway success I'm suddenly stuck with a large hosting bill. In that case I'd have to suddenly start charging users a recurring amount for apps that were previously free, or worse, already paid for.
I keep coming back to this idea of using OneDrive, or Dropbox, or some other free cloud hosting as a database. Here's how I see it working.
Lets say we have a todo app called Jobbie
- User installs Jobbie on both devices
- User logs into OneDrive on both devices, creating a "jobbie" sync folder in their OneDrive folder
- On Device A, User creates a new todo item "pick up dry cleaning"
- Device A uploads a text file to OneDrive with the name "20153001-pick_up_dry_cleaning.item".
- Device B scans the folder, finds a new file, and adds it to local database
- On Device B, User marks "pick up dry cleaning" as "done", and the file is renamed to "x20153001-pick_up_dry_cleaning.item" (or deleted)
- Device A scans the folder, sees the item has been renamed (or deleted) and removes it from local database
The obvious problems I see with this approach are
- items are limited to 255 - 9 characters (9 reserved for xYYYYMMDD), unless you want to download each file which would be quite slow
- there's no locking
Other than these two issues, are there any other problems I might face implementing such a system?
PS: I have also considered overwriting a stored SQLite file with a local copy but I figure this would be too much data overhead for a mobile device
UPDATE
I've accepted Peter Nied's answer below, which pointed out the issues I might encounter with such a system, which answered my question. However, Smarx pointed out in the comments that Dropbox has a free datastore API which I can use for my apps. This seems like a far better solution than trying to implement my own datastore on top of the file system, so I'm going with that.
UPDATE 2
The Datastore API was deprecated just 3 months after I updated the post, so its no longer available. Luckily I hadn't started developing against it at that point. You can use Dropbox as a standard flat-file storage very easily, but if you want to do any kind of sync you'll have to roll your own
UPDATE 3
June 2021
I did build something akin to "Jobbie" for personal use, but I ended up storing data in a text file using the Dropbox API, similar to how Todo.TXT works.
My Mobile app on Android (VueJs / Cordova) syncs my content changes to Dropbox, and then on any laptop I can open up the txt file in any text editor and make changes if I need to. It works very well for my use case.
Once or twice I've had the text file open in an editor with autosaving enabled (some markdown editor on Mac) and I have lost data when the latest version was overwritten with an older copy, but using Dropbox revision history it was easy enough to recover data.
If you're building a lightweight app and need to sync simple data between devices on the cheap, this works.