Это класс, который я использую
public class DBHelper extends SQLiteOpenHelper {
private static final String DB_FILE = "Database.db";
private static final String TABLE = "Estudiantes";
private static final String FIELD_ID = "id";
private static final String FIELD_NAME = "nombre";
private static final String FIELD_GRADE = "calificacion";
public DBHelper(Context context){
super(context, DB_FILE, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
String query = "CREATE TABLE " + TABLE + "(" +
FIELD_ID + " INTEGER PRIMARY KEY, " +
FIELD_NAME + " TEXT, " +
FIELD_GRADE + " INTEGER);";
db.execSQL(query);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
String query = "DROP TABLE IF EXISTS ?";
String[] params = {TABLE};
db.execSQL(query, params);
}
public void save(String nombre, int calificacion){
SQLiteDatabase db = getWritableDatabase();
ContentValues valores = new ContentValues();
valores.put(FIELD_NAME, nombre);
valores.put(FIELD_GRADE, calificacion);
db.insert(TABLE, null, valores);
}
public int delete(String nombre){
SQLiteDatabase db = getWritableDatabase();
String clause = FIELD_NAME + " = ?";
String[] args = {nombre};
return db.delete(TABLE, clause, args);
}
public int find(String nombre){
SQLiteDatabase db = getReadableDatabase();
String filtrito = FIELD_NAME + " = ?";
String[] args = {nombre};
Cursor c = db.query(TABLE, null, filtrito, args, null, null, null);
int result = -1;
if(c.moveToFirst()) {
result = c.getInt(2);
}
return result;
}
}
Это сообщение об ошибке, которое я получаю:
E/SQLiteLog: (1) table Estudiantes has no column named calificacion
E/SQLiteDatabase: Error inserting calificacion=80 nombre=Fer
android.database.sqlite.SQLiteException:
table Estudiantes has no column named calificacion (code 1): , while compiling:
INSERT INTO Estudiantes(calificacion,nombre) VALUES (?,?)