In my android project, I have a dynamically created SQLite Database which has multiple tables that save user-generated values. However, I also want a table in there which is pre-filled.
CONDITIONS:
-> These tables need to be in the same database, since I want to join them (And as far as I know, you can't crossjoin tables from different databases. At least that's not possible in MySQL)
-> I want the database to be dynamically created by the application, since I want to use the advantages of SQLiteOpenHelper.onUpgrade()
.
IDEAS:
The static table will only contain about 100 rows, which is why I considered putting all rows directly into the code (either directly as INSERT INTO
statements or in an ArrayList, for example). Once the database is created, the whole content from the ArrayList is copied into the table.
Problem: Then I have the same text twice on the user's phone - once as code and once in the database. 100 rows wouldn't really need much space; but as a good coder I still try to avoid this.
The second idea is very similar. On other threads, I have read that tables of SQLite can be saved as .csv files. They could be parsed by my android application and put into the table.
That would also result in having the data twice on the phone.
Is there a possibility which I am missing? I've made very much searches on google today but never found solutions to import tables into an Android SQLite database (only importing full databases).
Aucun commentaire:
Enregistrer un commentaire