Answer the question
In order to leave comments, you need to log in
Why doesn't SQLITE android work?
Hello!
Help, please with a problem. I am working with a database, I created the appropriate class, but I get an error
android.database.sqlite.SQLiteException: no such table: pictures (code 1): , while compiling: SELECT * FROM pictures
.
Tell me what am I doing wrong?
Class code for working with the database
public class DataBaseHelper extends SQLiteOpenHelper {
public static final String
CREATE_SCRIPT="BEGIN TRANSACTION; CREATE TABLE 'pictures' ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `name` TEXT NOT NULL, `description` TEXT, `author_id` INTEGER NOT NULL, `genre_id` INTEGER NOT NULL, `tech_id` INTEGER NOT NULL, `room_id` INTEGER NOT NULL,`notice` TEXT, `tags` TEXT, `photo` BLOB);COMMIT;",
DATABASE_NAME="paintings.db";
public static final int VERSION=1;
public DataBaseHelper(Context context) {
super(context, DATABASE_NAME, null, VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_SCRIPT);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
DataBaseHelper h = new DataBaseHelper(this);
SQLiteDatabase d = h.getReadableDatabase();
d.query("pictures", null, null, null, null, null, null); //тут вылетает исключение
h.close();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question