I'm very new to droid development but I was working on some SQL. I have an class which extends the SQLOpenDatabaseHelper and in the onCreate() method I execute this :
public static final String CREATE_DB = "CREATE TABLE " + TABLE_VOCAB_INFO
+ "(" + COLUMN_NAME + " TEXT NOT NULL PRIMARY KEY," + COLUMN_URL
+ " TEXT NOT NULL," + COLUMN_DOWNLOADED + "TEXT NOT NULL);";
However, when I try to add something to the database like so :
//Adding method
ContentValues cv = new ContentValues();
cv.put(COLUMN_NAME, "item " + i);
cv.put(COLUMN_URL, "random url");
cv.put(COLUMN_DOWNLOADED, "true");
open();
database.insert(TABLE_VOCAB_INFO, null, cv);
I get the error:
(1) no such table: vocab_info
How would I resolve this?
EDIT: more info.
I am creating the database in the onCreate() method of the helper like this:
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL(CREATE_DB);
} catch (SQLiteException e) {
System.out.println("Error with creation");
}
}
I access the database using the adding method like this
public void onClick(View viewSelected) {
switch (viewSelected.getId()) {
case R.id.bDownload:
DatabaseManipulator dm = new DatabaseManipulator(this);
dm.open();
dm.addList(null);
dm.addList(null);
dm.addList(null);
dm.addList(null);
dm.addList(null);
for (VocabList list : dm.getAllLists()) {
System.out.println(list.getName());
}
dm.close();
break;
Thanks in advance
COLUMN_DOWNLOADED + "TEXT NOT NULL);";CREATE_DBString, and when this putting data part is being executed.