Frage

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.

War es hilfreich?

Lösung

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.

Andere Tipps

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.

SQlite definitely way better in terms of performance and this gets even more important as the size of your data increases.

I've been working on a flutter app where I needed to display a filtered list of items dynamically based on typed text. I initially used a json file to store data and would read and store relevant values into a list, then filter this list as the user types.

This worked just fine with a few items so I thought I was fine until I tested with a real dataset which contained over 150,000 items. Trying to filter a list this large as a user types crashed the app. I moved to a database solution and all my problems were solved. Instant filtering and no more crashes

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top