SQLite Database on Android Not Storing Int Properly -
i creating android application keep track of recipes. able store , retrieve recipes, is_favorite
value not working correctly. when send boolean
value (based on whether checkbox
checked or not), correctly sent helper.insert
function:
public recipe insert(string name, boolean isfavorite, string servingsize, string time, string instructions) { contentvalues values = new contentvalues(); values.put("name", name); values.put("is_favorite", (isfavorite) ? 1 : 0); values.put("serving_size", servingsize); values.put("time", time); values.put("instructions", instructions); long id = databasehelper.getwritabledatabase().insert(database_table, null, values); }
when @ values
, is_favorite
1 if isfavorite
true , 0 if isfavorite
false, want.
but when helper.getbyid(int id)
recipe created, returns 0 is_favorite
column, no matter value put in there. query pretty standard:
select _id, name, is_favorite, serving_size, time, instructions recipes _id = ?
here table creation script:
create table recipes (_id integer primary key autoincrement, name text, is_favorite integer, serving_size text, time text, instructions text);
any suggestions appreciated. if more information needed, let me know.
thanks!
update: responses! i'm still not entirely sure problem was, after force stopping, clearing data, , uninstalling app re-installing it, worked fine...
it sounds problem insert function then. sure database_table
table you're selecting on? i'd experiment, , change name of "is_favorite
" else , see if behavior persists our different result. have had weird issues "hidden" characters mess strings. changing name of removes conflict well.
this reason use constants keys, (instead of hardcoded keys)
Comments
Post a Comment