Thursday, 15 March 2012

java - SQLite select not working with Where clause -



java - SQLite select not working with Where clause -

i trying info sqlite table, running query:

sqlitedatabase db = this.getwritabledatabase(); // int memberid = 1234 cursor rs = db.rawquery("select username, password users memberid = ? limit 1", new string[]{string.valueof(memberid)}); system.err.println("rows: " + rs.getcount());

the output rows: 0

but when run query:

cursor rs = db.rawquery("select username, password, memberid users limit 1", new string[]{}); rs.movetofirst(); system.err.println(rs.getstring(0) + ":" + rs.getstring(1) + ":" + rs.getstring(2));

i username:xxxx:1234

how come when add together where clause breaking?

as @ryan naddy pointed out - difference between exposition 1 , exposition 2 phone call "movetofirst()" - need cursor positioned before first entry.

see article.

java android sqlite

No comments:

Post a Comment