Using java Syntax Highlighting
- private static final String DATABASE_CREATE =
- "create table hours (_id integer primary key autoincrement, "
- + "day text not null, hour integer not null, "
- + "minutes integer not null);";
- private static final String DATABASE_NAME = "data";
- private static final String DATABASE_TABLE = "hours";
- private static final int DATABASE_VERSION = 2;
- private static class DatabaseHelper extends SQLiteOpenHelper {
- DatabaseHelper(Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- }
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.execSQL(DATABASE_CREATE);
- }
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
- + newVersion + ", which will destroy all old data");
- db.execSQL("DROP TABLE IF EXISTS notes");
- onCreate(db);
- }
- }
Parsed in 0.039 seconds, using GeSHi 1.0.8.4
My open function I call:
Using java Syntax Highlighting
- public HoursDbAdapter open() throws SQLException {
- mDbHelper = new DatabaseHelper(mCtx);
- mDb = mDbHelper.getWritableDatabase();
- return this;
- }
Parsed in 0.040 seconds, using GeSHi 1.0.8.4
It's my understanding that DatabaseHelper.getWritableDatabase() will run my create database statement, if the database doesn't exist yet. However, when I try to fetch any rows after opening it here, I get this error:
no such table: hours: , while compiling: SELECT _id, day, hour, minutes FROM hours
Am I missing something? (Probably simple and obvious, if I am. :S)



