Mostly desperation - I will give your idea a try though - thanks! Mikey
On 16 Jun 2010, at 21:04, Justin Anderson wrote: > I'm not entirely sure, but I noticed my code is a little different than > yours... > > Before I loop over the rows in the cursor I call moveToFirst(). So, with > your code that would be c.moveToFirst() right before the while loop. I seem > to remember having some weird issues with the Cursor class but haven't had > any since I've made this change. > > Also, why are you setting c to null? There really is no point in doing that > as the garbage collector will get called on you move out of c's scope... > which happens as soon as you leave the try block. > > Thanks, > Justin > > ---------------------------------------------------------------------- > There are only 10 types of people in the world... > Those who know binary and those who don't. > ---------------------------------------------------------------------- > > > On Wed, Jun 16, 2010 at 12:13 PM, Mikey <[email protected]> wrote: > Hi, > > I am using a a Sqlite database in my application, but I am having a problem > with it crashing (seemingly) randomly with the exception in Cursor. (I have > been unable to recreate the error to give you the exact exception but it is > something like the cursor being in an invalid state. > > I am using the cursor as follows: > > public ArrayList<String> fetchPermanent() { > ArrayList<String> rows = new ArrayList<String>(); > try { > Cursor c = mDb.query(USERS, new String[] {SCREEN_NAME}, > CONSTANT + "='C'", null, null, null, null); > if (c != null && c.getCount() > 0) { > while (!c.isLast()) { > c.moveToNext(); > rows.add(c.getString(0)); > } > c.close(); > c = null; > } > } > catch (Exception e) { > Log.e("DBERR", e.getMessage()); > } > return rows; > } > > Does anyone here have any idea what it is I am doing wrong? > > Mikey > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

