I have an Android application that should check if there is a record in the database, and if not, process some things and, ultimately, insert them and just read the data from the database if the data really exists. I am using a subclass of SQLiteOpenHelper to create and retrieve a rewritable instance of SQLiteDatabase, which I thought automatically took care of creating the table if it does not already exist (since the code for this is in onCreate (...)).
However, when the table does not exist yet, and the first method runs on the SQLiteDatabase object, I have a query call (...), the error "I / Database (26434) is displayed in my logarithm: sqlite return: error code = 1, msg = no such table: appdata ", and, of course, the appdata table is not created.
Any ideas on why?
Iβm either looking for a method to check if a table exists (because if itβs not, the data is certainly not in it, and I donβt need to read it until I write to it, which seems to create the table correctly) or a way to make sure that it is created and just empty by the time the request is first called (...)
EDIT
This was published after two answers below:
I seem to have found a problem. For some reason, I decided that a different SQLiteOpenHelper should be created for each table, although both access the same database file. I think that refactoring this code uses only one OpenHelper, and creating both tables inside it onCreate might work better ...
android database sqlite
camperdave Jun 17 '10 at 4:40 2010-06-17 04:40
source share