Reputation: 1192
I save data in a SQLite Database. The user can choose under which name his data will be saved. But how to get the row?
I'm trying this:
public Cursor getRowByName(String rowName) {
Cursor c = db.query(true, DATABASE_TABLE, ALL_KEYS,
KEY_SAVENAME + "=?", new String[]{rowName}, null, null, null, null);
if (c != null) {
c.moveToFirst();
}
return c;
}
But get the error:
E/AndroidRuntime﹕ FATAL EXCEPTION: main
android.database.sqlite.SQLiteException: no such column: max (code 1): , while compiling:
SELECT DISTINCT _id, saveName, date, time, month, erg, ergg, m, p, c, cg, x1, x2,
x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, y1, y2, y3, y4,
y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15, y16, c1, c2, c3, c4, c5, c6,
c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, max, min, year FROM mainTable WHERE saveName=?
First it worked without the column max
but afterwards I recognized that I need this and furthermore columns. But even if I had one more column (like max
), I get this error.
What am I doing wrong?
Upvotes: 0
Views: 213
Reputation: 38098
When you change the database structure, you must increase the DATABASE_VERSION constant value, in order for the onUpgrade()
method to fire (it will delete and recreate the table/s).
Upvotes: 1