开发者

What is the best method to store this small read-only data table in an android phone?

I need to store data to use in my android program. Here are t开发者_C百科he details about the data:

  • There will be one table. Each "row" of data will have a unique INT identifier. Other then that field, there will be four other INT fields and a text field. The string field will probably be a 2 or 3 sentences long. Each of the 4 INT fields will correspond to the ID of other rows.

  • There will be 100 rows, maybe 200. But all the rows will be read-only, and pre-populated.

  • The data will be read frequently, and non-sequentially.

The first answer for storing data is SQLite a lot of times, but given the particulars of the data, another storage method might be more efficient. I'm open to any suggestions, and code examples are always welcome!


How about a static xml or cvs file in your assets? If it's too slow to access the file each time you need it (since you say it'll be read frequently), you could simply parse it into a map (HashMap or whatever it is in Java) when your program starts. You could also read it into SQLite the first time your program is run, and then use that database from there on, but you probably don't need to do that.


Method 1, use SQLite, it works well and is in Android already. There is an sqlite example on the net (sorry I have lost the url) - google it :)

Method 2, write a streamed file to your SD Card with your data! there is an example in ApiDemos that does that and just add a file reader to collect your data from a sequential flat file. Nom.

Method 3, Write it as a post to the cloud. Am looking for code to do that myself, please post some here to save me time......

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜