Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

I want to store around a thousand strings (like some quotes) and populate a ListView or ListFragment using them. These strings are static and not likely to change once loaded.

It is a read-only data and user should not be allowed to manipulate it.

Should i store them using XML file or a text file, or what could be the best approach?

like image 459
Divya Motiwala Avatar asked Apr 02 '13 10:04

Divya Motiwala


3 Answers

Use Sqlite db thats the efficient and secure way

like image 193
Viswanath Lekshmanan Avatar answered Sep 28 '22 16:09

Viswanath Lekshmanan


Shared Prefrences is the best way to store small data. You Can take help from this tutorial

like image 34
hemantsb Avatar answered Sep 28 '22 16:09

hemantsb


If the data are not going to change in the entire application development why u not going for static final way using with any access modifier as u like and u can use them in your application and as size concern thousand or lakh of String data is not going to effect as we know also String is immutable and can't change throughout the app life and one more thing with declaring as final so reinitialize will not be there but only reusing.Declare all the string in the as the class part so it load when class load i.e. once.If any more thing let me know.

like image 29
blackjack Avatar answered Sep 28 '22 15:09

blackjack