Search code examples
androidsqliteflat-file

Android Performance : Flat file vs SQLite


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.


Solution

  • 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.