Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 the 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!

like image 860
Bromide Avatar asked Jul 24 '10 02:07

Bromide


People also ask

What is the best way to store data on Android?

When storing sensitive data—data that shouldn't be accessible from any other app—use internal storage, preferences, or a database. Internal storage has the added benefit of the data being hidden from users. Android provides two types of physical storage locations: internal storage and external storage.

How to read and write files in Android internal storage?

To read and write in the android internal storage we have two methods OpenFileOutput (): used for creating and saving a file. This method returns a FileOutputStream instance. Context.MODE_PRIVATE: If the file exists then it is overiddent else a new file is created.

What are the two types of storage in Android?

Categories of storage locations Android provides two types of physical storage locations: internal storage and external storage. On most devices, internal storage is smaller than external storage. However, internal storage is always available on all devices, making it a more reliable place to put data on which your app depends.

What type of data should I store in my App?

If you have data that's only meaningful for your app, use app-specific storage. For shareable media content, use shared storage so that other apps can access the content. For structured data, use either preferences (for key-value data) or a database (for data that contains more than 2 columns). Should the data be private to your app?


1 Answers

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.

like image 78
Benny Jobigan Avatar answered Oct 21 '22 04:10

Benny Jobigan