sqlite - Cannot select columns from Database with Android Cursor -


i'm trying grab every single row in sqlite database on android , grab each individual column each row. believe data in database, because call separate function datahelper.selectall() print out log of data. data expect correctly shows in logcat in eclipse. if it's important, datahelper.java program i'm using found here: http://www.screaming-penguin.com/node/7742. i'll post relevant code below. important stuff in dopost().

    // inside oncreate of main (which extends activity)...     button buttonpost = (button) findviewbyid(r.id.buttonpost);     buttonpost.setonclicklistener(new onclicklistener() {      // doesn't post website yet      public void onclick(view v) {       log.d(tag, "in onclicklistener.");          connectivitymanager connmanager = (connectivitymanager) getsystemservice(connectivity_service);          networkinfo mwifi = connmanager.getnetworkinfo(connectivitymanager.type_wifi);           if (mwifi.isconnected()) {           log.d(tag, "connected, calling dopost()!");           if (dopost()) {                       // ...                 }             }      }     });   public boolean dopost() {    boolean outcome = false;    long ret = dh.insert(main.id++ + "," + "my test2" + "," + "5:4:2:3" + "," + -300 + "," + -300 + "," + -1 + "," + -70 + "," + 3 + "," + -3 + "," + main.device_id);    log.d(tag, "ret static insert:" + ret);     cursor cursor = this.dh.db.query(datahelper.table_name,        new string[] { "id", "rssi", "wap_id", "lat" },       null, null, null, null, "id desc");    log.d(tag, "cursor column count: " + cursor.getcolumncount());    if (cursor.movetofirst()) {      {         httppost post = new httppost(our_server);        log.d(tag, "rssi index:" + cursor.getcolumnindex("rssi"));        log.d(tag, "the rssi: " + cursor.getint(cursor.getcolumnindex("rssi")));      } while (cursor.movetonext());    }     // release connection here?    cm.shutdown();     if (cursor != null && !cursor.isclosed()) {       cursor.close();    }  return outcome; } 

now what's strange in logcat printed out full rows (just string), know i'm able access database. rssi values expect not logged, instead get:

cursor column count: 4 id value: 6 id index: 0 rssi index:1 rssi: 0 id value: 5 id index: 0 rssi index:1 rssi: 0 

i'm @ loss, because plenty of online examples access data same way. have fact i'm within onclicklistener? there no debugger warnings when this.

thanks!

nevermind. turns out datahelper.java class using inserts first column. pretty counter-intuitive. that's finding code online , assuming right thing.

to fix this, manually wrote full sql statement, compiled statement, , ran it.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -