我有两个表Materias(纪律)和Grade(网格)。首先我从表中调用活动Materias并插入一些行,然后我调用Grade活动。它有一个来自 的参考列Materias,但是当我内部加入这些表时,我收到致命异常,说这条消息:SQLiteException: no such table: Materias (code 1): , while compiling: SELECT g.*, c.Descricao FROM Grades g INNER JOIN Materias m ON m.id = g.materia"我的材料DAOpublic class MateriaDAO extends SQLiteOpenHelper { public final String tabela = "Materias"; public MateriaDAO(Context context) { super(context, "Materias", null, 2); } @Override public void onCreate(SQLiteDatabase db) { String comando = "CREATE TABLE " + tabela + " ("; comando += "id INTEGER PRIMARY KEY,"; comando += "Descricao TEXT,"; comando += "Comentario TEXT,"; comando += "Qtd_Aulas INTEGER,"; comando += "Qtd_Faltas INTEGER)"; db.execSQL(comando); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { String sql = "DROP TABLE IF EXISTS " + tabela; db.execSQL(sql); onCreate(db); } public void insert(Materia o) { try{ ContentValues cv = new ContentValues(); cv.put("Descricao", o.getDescricao()); cv.put("Comentario", o.getComentario()); cv.put("Qtd_Aulas", o.getQtdAula()); cv.put("Qtd_Faltas", o.getQtdAula()); getWritableDatabase().insert(tabela, null, cv); } catch (Exception ex) { throw ex; } } public void update(Materia o) { ContentValues cv = new ContentValues(); cv.put("Descricao", o.getDescricao()); cv.put("Comentario", o.getComentario()); cv.put("Qtd_Aulas", o.getQtdAula()); cv.put("Qtd_Faltas", o.getQtdAula()); String[] args = {o.getID() + ""}; getWritableDatabase().update(tabela, cv, "ID=?", args); }
添加回答
举报
0/150
提交
取消