I need to store my android app content and want tips on what storage i should use. SQLite database or XML file(s)?
Some characteristics of the app and the data:
- The application is used for tracking (daily) the body measurements of weight, waist, chest, ++
- The measurement types are divided in separately tabs and are not dependent on/related to each other
- Entities contains small amount of data, 4-5 attributes
- The amount of data is expected to be moderate. Maximum (30 measurement in the months x 5 measurement types = 150 measurements in months/1800 in the year)
- None advanced queries are going to be used. Mainly reading (all data elements) and adding new measurements.
- I want to enable easy sharing/exporting of the measurement data to for instance dropbox or email.
I guess that there are none performance issues storing the data in XML-file with these requirements/characteristics. If so, should I separate each measurement type in separately XML-file and where on the mobile device should I store the files?
I would read over the Storage Options you have available on Android to try to dig up some more information.
What you described, one time writing to files that are in drop box seems like writing out to an XML file that is saved in your dropbox seems like a good choice. No complexed queries, just read in one record at a time.
However, I feel it wouldn’t be that much more work to go with a SQL database. And this would be way more flexible in the long run. Right now you don’t want to do queries, but you may some day. Plus you won’t have to worry about splitting your data into several files and parsing things. Parsing can quickly become bothersome when you try scaling.
What I would recommend is to write a ContentProvider and then put all your details in there. That way your program won’t care about how the data is stored in case you want to change it later because the Provider does all heavy lifting for you. I would much rather use a CursorAdapter than anything else, and your get from using SQLite. Plus all the new CursorLoader keep up the performance of you application.