Android : Sqlite database no such column

on Friday, October 10, 2014


my app is working on difference type of phone but when i tested it on LG G2 i get this exception :


no such column:1 (code 1):, while compiling: UPDATE dbName Set favorite=1 WHERE id=1410876099320;


what is the problem ? my column name is favorite but it gives me no such column:1


how i adjust it:



public boolean adjustFavorites(List<Info> infos, boolean set) {
String format = "UPDATE %s SET %s=%d WHERE %s=%d;";
if (set)
for (Info info : infos) {
long id = info.getId();
String query = String.format(format, TABLE_NAME, DB_COL_FAVORITE, 1, DB_COL_ID, id);
database.execSQL(query);
}
else
for (Info info : infos) {
long id = info.getId();
String query = String.format(format, TABLE_NAME, DB_COL_FAVORITE, 0, DB_COL_ID, id);
database.execSQL(query);
}

return true;
}

0 comments:

Post a Comment