android - SQLite no such column error -
hi can please me below error in android sqlite ? appreciate!
caused by: android.database.sqlite.sqliteexception: no such column: house (code 1): , while compiling: select * category category =house
below part of code in have inserted "house" in table
public void oncreate(sqlitedatabase db) { string create_category_table = "create table category( " + "_id integer primary key autoincrement, " + "category text unique)"; db.execsql(create_category_table); } public void addcategory(string name){ sqlitedatabase db = this.getwritabledatabase(); contentvalues cv = new contentvalues(); cv.put("category", name); db.insert(category_table, // table null, //nullcolumnhack cv); // key/value -> keys = column names/ values = column values db.close();} public list getcategory(){ list<string> list=new linkedlist(); sqlitedatabase db = this.getreadabledatabase(); cursor cursor = db.rawquery("select * category category =house" , null); // 3. if got results first 1 if (cursor != null) cursor.movetofirst(); { string s = (cursor.getstring(1)); list.add(s); }while (cursor.movetonext()); return list; }
you need wrap house single quotes
db.rawquery("select * category category = 'house'" , null);
Comments
Post a Comment