simplecursoradapter - Fetch all notes returns zero rows from Android notepad example -


well stupid question simple answer when using simple cursor adapter notepad example, list of names database.

when try "manually" moving cursor on rows , extracting names cursor says there 0 rows returned...

this works per example:

cursor notescursor = mdbhelper.fetchallnotes();     startmanagingcursor(notescursor);      // create array specify fields want display in list (only name)     string[] = new string[]{weightsdatabase.key_name};      // , array of fields want bind fields (in case text1)     int[] = new int[]{r.id.weightrows};      // create simple cursor adapter , set display     simplecursoradapter notes =              new simplecursoradapter(this, r.layout.weights_row, notescursor, from, to);     setlistadapter(notes); 

now i'm trying it's not quite working. simple cursor adapter doing special i'm not?

//check # of rows, returns 0     int mone = notescursor.getcount();     //initial random string array     string[] temp = new string[100];     int = 0;     notescursor.movetofirst();     do{          temp[i]=notescursor.getstring(notescursor.getcolumnindex(weightsdatabase.key_rowid)); //crashes here         //index out of bounds         i++;     }while(notescursor.movetonext()); 

i have gotten work, returning specific query return row name "_". different returning notes?

movetofirst() returns boolean, can prevent exception being thrown checking value before attempt read cursor:

if (notescursor.movetofirst()) {     // loop } 

as why there 0 rows, attempting re-use same cursor passed simplecursoradapter, or code failing stand-alone? if attempting re-use it, try using new cursor after performing fresh fetchallnotes().


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -