How does a CSV database compare to an SQLite database in Android?
Looking at other questions on StackOverflow, and reading Android Developer Documentation, I have seen SQLite databases being used far more often than reading data from a CSV file. There are also some questions where users have wanted to import a CSV file into an SQLite database (for example, this question or this one). Is there an advantage to using SQLite over CSV?
I have tried using both CSV and SQLite a little, and in terms of performance I don't see a huge difference, but correct me if I'm wrong here.
As I know there are different methods of reading a CSV file, I opened and read it using the BufferedReader
like so:
BufferedReader reader =
new BufferedReader(new InputStreamReader(context.getAssets().open(fileName)));
And the SQLite database was opened in the usual way:
SQLiteDatabase db = helper.getReadableDatabase();
I'm not too sure about differences in functionality, although I am assuming SQLite is easier to manage and filter through, and that's why I'm asking this question.
So to summarise:
- Are any of the two faster in terms of performance?
- Does SQLite (or CSV) have any additional functionality that the other does not, especially in Android (as I am aware Android has its own
SQLiteDatabase
class? - Why does it seem that SQLite is used far more than CSV databases (i.e. reading and filtering a CSV file)?
EDIT:
Just to clarify, I know a CSV file is just a file with commas separating values, i.e. not a 'database' as a SQL database is. However I can still use a CSV file as a sort of database, where the comma separated values indicate different columns, which can also be filtered, by checking to see if a particular column matches a particular value. So I am asking which is better to read data from.