开发者

HashMap v/s Database . Which one is better?

I want to store track_id and playlist name to display playlist name . So please help me what should i use ?

HashMap o开发者_JAVA技巧r database ?


If you need it to be saved after you close the application, you must need something else then a HashMap, because it will be removed from memory. So you might need a database (or some serialisation to file) after all.

You could save it as a database for persistence, and load it into a datastructure for performance when your app runs. It's hard to say without any information, but maybe a HashMap isn't the best 'soft' sollution either. If you're just saving a list, it might not be your best choice.


The third option would be using a HashMap in your program and storing the HashMap to a XML file for persistence.


If you want persistence then use a database, otherwise, a HashMap will be just fine. As the size of data grows, HashMaps will give better performance over the database. However, they will require more memory as the entire "database" will be stored in RAM for the application's lifetime.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜