Android Performance : Flat file vs SQLite

本秂侑毒 提交于 2019-12-28 06:28:23

问题


There are few questions related to this topic on stackoverflow, But I didn't get the proper answer. I have some doubts on performance of flat files, Is it better to use flat files instead of SQLite ? Can anybody have performance statistics ? Or example of proper way to code flat file in android.


回答1:


Aside from performance benefits, here's a simple list of advantages of using SQLite rather than flat file:

  • You can query items as you wish -- don't need to load all of them and select which ones you need.
  • Deleting records is a much less painful process. No rewriting of whole files into wherever.
  • Updating a record is as easy as removing or creating one.
  • Have you ever tried doing cross-referencing lookups on a flat file? Not worth it.

To summarize, it's every advantage a Database has over a text file.




回答2:


It depends on your requirement.

If your storage data size is structured-bulky in size then i suggest you for SQLite. On the other hand if the data size is just a single or few lines then flat file is best option.

What makes difference between them is, SQLite stores data in structured format, so it will be easier to find a record from multiple set of records which is very tedious process in case of flat file.

However when if you are storing blob kind of data then it is suggested to use combination of both, SQLite and file system both. i.e. store the image/sound/video data as file format and store their path in SQLite.

Also visit this accessing performance.



来源:https://stackoverflow.com/questions/12212640/android-performance-flat-file-vs-sqlite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!