I am storing simple data and my boss is keen on using a key-value pair database to do so. The developer before me chose SnappyDB, which is a NoSQL database similar to Mongo, Couch, and Redis.

SnappyDB: https://github.com/nhachicha/SnappyDB

Why can't I just use Shared Preferences? This is also a key/value pair database, isn't it?

Why would I choose anything other than Shared Preferences for simple key/value storage? Why would I ever use an external NoSQL database?

Note: I am saving XML strings representing each employee in a company. There can be many employees that belong to a single company. From what I understand, there's no limit to the size of android Shared Preferences, beyond how much space is available in storage, so even if the employee list grows into the 1000s that shouldn't be a problem, right?


Why can't I just use Shared Preferences? This is also a key/value pair database, isn't it?

Because that's not what it's intended for? See https://www.journaldev.com/9412/android-shared-preferences-example-tutorial for a decent tutorial on its usage. It is a database, but one specifically intended for storing application preferences.

It sounds like you need a more general solution. I'd likely use SQLite, but if your boss wants a NoSQL solution, SnppyDB looks suitable. Why not use it?

| improve this answer | |
  • Snappy DB is slower than Shared Preferences for Read/Write operations (even though it is still lightweight). Snappy DB also might not be around for long (the developer hasn't touched it in a while), while Shared Preferences will almost certainly always but supported. I agree that SQL would be the better approach but my boss wants data retrieval to be as fast as possible, and snappy is faster. Shared Preferences is even faster than that, and there doesn't seem to be anything stopping me from using it. It will get the job done, won't it? – Michael Kemp Apr 15 '19 at 14:08
  • What device do you have, and what qualifies as "slower"? What is the visible difference you see between Shared Preferences and Snappy DB? – DMcCunney Apr 15 '19 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.