Should I use plain text files or sqlite database on my Android app?
I developed An android app to read the books of Pope Shenouda III in Arabic
. I used plain text files as a storage. Each chapter of each book is a plain text file called for example a1.txt
.
I want to add more books quicker and it’s relatively easy and straightforward. But I also want to add search functionality. Searching in plain text files is not that hard! but search SQLite database is faster, efficient and overall better.
But I thought of a question. Is plain text files bigger? which is more bloated? which of them takes more space?
Maybe the database takes more space as it has more structure and features. But maybe the database takes less space as it is stored and compressed more efficiently.
After talking with Bard , ChatGPT and Phind , I decided to migrate the data of books into an sqlite database and test this case and report it here on this post.
I migrated 18 books from plain text files into SQLite database. The database is smaller and of course has more features! I am mindblown right now.
But the plain text files are not compressed at all.
books.db 4.9MB
books/ 6.4MB (not compressed)
comparison of plain text files and sqlite db for storage
I decided to use SQLite database, and deprecate the plain text files I was using. After I complete migration and add more functionalities and features, I’ll update this post with more information. Stay tuned.
I hope this post helps you. If you know a person who can benefit from this information, send them a link of this post. If you want to get notified about new posts, follow me on YouTube , Twitter (x) , LinkedIn , and GitHub .