android - SimpleAdapter needs an _id field -


i got :

cursor c = db.query("org", null, null, null, null, null, null);

which means choose table "org", need make :

 cursor c = db.rawquery(" select "+ id + " _id") 

because simpleadapter need have _id field reason or crash error. how combine 2 1 query?

for statement : cursor c = db.query("org", null, null, null, null, null, null); second parameter wrong, shoukd mention column names in it.

public cursor query (boolean distinct, string table, string[] columns, string selection, string[] selectionargs, string groupby, string having, string orderby, string limit) 

whereas for,

cursor c = db.rawquery(" select "+ id + " _id org");  

means select id , create alias of using as _id, , selecting id from org table. able access result query column name _id, , in order access result use:

c.movetofirst();     while (c.movetonext()) {  system.out.println(c.getstring(c.getcolumnindex("_id"));  } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

django - CSRF verification failed. Request aborted. CSRF cookie not set -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -