What is the fastest / preferred way to store static data in android?

I want to store about a thousand lines (for example, some quotation marks) and use their ListView or ListFragment . These lines are static and are unlikely to change after loading.

This data is read-only and the user is not allowed to manipulate it.

Should I store them using an XML file or a text file, or what could be a better approach?

+6
source share
5 answers

Use Sqlite db, which is an effective and safe way.

+3
source

General preferences are the best way to store small data. You can get help from this tutorial.

+3
source

If the data will not change throughout the development of applications, why are you not going to use a static final , using with any access modifier , like you, and you can use it in your application and as a size refer to thousands or lakh of String data that will not implemented because we know that String is immutable and cannot change throughout the life of the application and one more thing with the declaration as final , so reinitialization will not be present, but only reuse. Select the entire line in the class so that it loads when the class loads, i.e. once. If anything else tells me.

+1
source

Will it ever change?

String data type?

Do you already have them when creating the application?

Just save them in the Resources section of the line; just like you store values ​​like 'appname' you can save one huge string variable, separated by line breaks (or commas, colons, etc.), then use java string or tokenize utilities to get each substring or all that seems appropriate to you according to what he has

0
source

Just put them in a text file that you store in the resource folder. If you put them in rows, you already have your items.

0
source

All Articles