Error in database does not see column OS error - 11:Try again

Viewed 35

I ran into such a problem, at the beginning of creating the application I made a database, then I needed to refer to it and I get the error "no CollectionId column", changing the version of the database did not help. Please let me know what could be the problem Thank you in advance

DB

public static String TABLE_NAME = "CollectionPhoto";
    public static String COLLECTION_ID = "CollectionId";
    public static String FILE_NAME = "FileName";
    public static String FILE_NAME_SAMPLE = "FileNameSample";
    public static String DESCRIPTION = "Description";

public static void createTable(SQLiteDatabase db) {
        db.execSQL("drop table if exists " + TABLE_NAME);
        db.execSQL("create table " + CollectionPhotoTable.TABLE_NAME + " ("
                + "_id integer primary key autoincrement,"
                + CollectionPhotoTable.COLLECTION_ID + " text,"
                + CollectionPhotoTable.DESCRIPTION + " text,"
                + CollectionPhotoTable.FILE_NAME + " text,"
                + CollectionPhotoTable.FILE_NAME_SAMPLE + " text);"
      

Location of error

public Cursor cursor(String _collectionId) {
        return GlobalVars.db.rawQuery("select * from CollectionPhoto where CollectionId = ? ", new String[]{_collectionId});
    }

DBHelper

void createTables(SQLiteDatabase db) {
    CollectionPhotoTable.createTable(db);
    }
 static void deleteTables(SQLiteDatabase db) {
        db.beginTransaction();
        db.execSQL("drop table if exists CollectionPhoto");
        db.endTransaction();
    }
 @Override
    public void onCreate(SQLiteDatabase db) {
        createTables(db);

    }
 @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        deleteTables(db);
        createTables(db);
    }

ERROR

Caused by: android.database.sqlite.SQLiteException: no such column: CollectionId (Sqlite code 1 SQLITE_ERROR): , while compiling: select * from CollectionPhoto where CollectionId = ?, (OS error - 11:Try again)
0 Answers
Related