Possible Duplicate:
Android Sqlite - “No Such Table” Error
We are trying to develop an application on Android. We are using SQLite database and on phone we are getting
SQLiteException:no such table.
It is working fine on simulator.
Can anyone provide any input on this?
If you don't specify the database file name correctly I believe it falls back to creating an empty database. This is generally the cause of 'table not found'. Check your path and database file name.
I had faced a different flavour of the same problem.
I was getting no such table
error when I try to insert.
Before inserting, the code was calling
mDb = mDbHelper.getWritableDatabase();
getWritableDatabase()
, when called first time will call onCreate()
I had my SQL query to create the table within this oncreate method
public void onCreate(SQLiteDatabase db) {
db.execSQL(DATABASE_CREATE);
Log.v("INFO1","creating db");
//Toast.makeText(mCtx, "created", Toast.LENGTH_SHORT).show();
}
So for me what had happened was, the db
was successfully created when the application was first run but no table due to some other errors.
Later whenever the application is run, onCreate()
is never called as db
is already there and thus no table created, so all further SQL commands failed.
So I moved creating table out of onCreate()
, and now its working
Some people have been able to solve the problem using the steps mentioned here. It seems to me that this problem exists on certain versions of Android 2.2. I have incorporated this change in my code, though I'm still looking for Beta testers with to see if it actually works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With