I have the following code (I simplified it & removed unrelevant parts)
public class MyDatabaseManager extends SQLiteOpenHelper {
private SQLiteDatabase myDatabase;
public DatabaseManager() {
super(MyApp.getAndroidContext(), DATABASE_NAME, null, DATABASE_VERSION);
myDatabase = getWritableDatabase();
}
@Override
public void onCreate(SQLiteDatabase database) {
database.execSQL("create table t1 (t1key INTEGER PRIMARY KEY,data TEXT,num REAL,timeEnter NUMERIC);");
}
@Override
public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
}
}
Now when I run queries against this database I get sqlite - no such table exception.
My breakpoint at database.execSQL hits and it doesn't raise any exception(for example if I change the code to database.execSQL("asda") I get syntax error exception) so I think my SQL code is correct. Yet the table is not created.
I copied the database file to my pc and I looked in it with Sqlite browser and indeed my tables don't exist there. There is only one table and that is something called android_metadata. Any ideas?
getApplicationContext()MyApp.getAndroidContext()simply returns theprivate static android.content.Context m_Context;, it is initialized withinMyApp.onCreate()with the codem_Context = getApplicationContext();