What is the advantage of Using SQLite rather than File?

前端 未结 2 1142
粉色の甜心
粉色の甜心 2020-12-08 03:32

In Android, entering data in SQLite uses more time and more lines of codes than in .txt file.

Saving data in .txt and use FileReader is convenient to get the data.

2条回答
  •  执笔经年
    2020-12-08 04:01

    The main reasons which immediately spring to mind, which SQLite gives you and a simple file does not:

    • http://en.wikipedia.org/wiki/ACID
    • A standard API: SQL
    • Theoretically better performance (say, O(log n) rather than O(n))
    • No wheel reinventing
    • and plenty of others

    Note that trying to solve any of these problems with using a flat file yourself is going to start moving into database territory – but of course you really don't want to write that sort of thing yourself.

提交回复
热议问题