I’m working on an android app and here i have few data objects (1000 s).. as of now i put them in hashTable and store hashtable in a file.. i’m not really satisfied with what i have done since it may increase heap size (?) and app may start freezing (Atleast when there are too many data objects..)
my question is , is this a good way to store data and are there any chances that my app will crash or slow down…
Thank you..
First you need to decide which data needs to be kept in memory (the data that your application needs to access quickly), and what data needs to be stored to be retrieved once needed.
Typically, I would think of the application having all its data stored on the database, and you would load in memory only the data that are most-likely going to be used.
That most-likely depends on your application, you might want to risk loading data that are not going to be used (consuming more memory but having a better performance), or you might go the opposite direction.
The data stored on a file, are not in the Java Heap, variables and objects exists in the heap, files don’t.
And you should consider using SQLite instead of a file.