javaandroidsqlitedocumentdocument-storage

File-based Document Storage in android


I'm in the early stages of a note-taking application for android and I'm hoping that somebody can point me to a nice solution for storing the note data.

Ideally, I'm looking to have a solution where:

XML is out (at least for the entire file), since I don't have a good way to extract a single page at a time. I considered using zip files, but (especially when compressed) I think they'd be stuck loading the entire file as well.

It seems like there should be a Java library out there that does this, but my google-fu is failing me. The only other alternative I can think of is to make a separate sqlite database for every note.

Does anybody know of a good solution to this problem? Thanks!


Solution

  • Seems like a relational database would work here. You just need to play around with the schema a little.

    Maybe make a Pages table with each page including, say, a field for the document it belongs to and a field for its order in the document. Pages could also have a field for binary data, which might be contained in another table. If the document itself has additional data, maybe you have a table for documents too.

    I haven't used SQLite transactions on an Android device, but it seems like that would be a good way to address thread safety.