Question

I am looking for a lightweight embedded database to store (and rarely modify) a few kilobytes of data (5kb to 100kb) in Java applications (mostly Android but also other platforms).

Expected characteristics:

  • fast when reading, but not necessarily fast when writing
  • almost no size overhead (kilobytes used even when there is no data), but not necessarily very compact (kilobytes used per kilobyte of actual data)
  • very small database client library JAR file size
  • Open Source

QUESTION: Is there a database format specialized for those tiny cases?
Text-based solutions acceptable too.

If relevant: it will be this kind of data.

Was it helpful?

Solution

Stuff it in an object and serialize it out to a file. Write the new file on save, rename it on top of the old one to "commit" it so you don't have to worry about corrupting it if the write fails. No DB, no nothing. Simple.

OTHER TIPS

If you can use flat (text) files, you could keep the file on disk and read/seek around. Never read it all in at once. If you need e.g. a faster index, maybe you can build the index and a record number and use the index to find the right "rows" and use the record number to get the rest of the data from a constant size field database or as a line number in a text file.

I don't know about this Java and that static initializer message, but that sounds to me like a code size limit, not data? Why would the runtime data affect bytecode?

Can't suggest specific libraries. Maybe there's some Berkeley DB, DSV or xBase style library around.

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