Re: [android-beginners] Problem with cursors
Well, thanks - that seems to have done the trick, but now I am getting another error with another method - maybe you can tell me if you do things differently here as well? public boolean isPermanent(String screen_name) { boolean output = false; try { Cursor c = mDb.query(USERS, new String[] {CONSTANT}, SCREEN_NAME + =' + screen_name + ', null, null, null, null); if (c != null c.getCount() 0) { c.moveToFirst(); output = c.getString(0).contentEquals(C); c.close(); } } catch (Exception e) { Log.e(DBERR, e.getMessage()); } return output; } What is really annoying is that the exception is not caught in my handler, but in the System Daemon thread :o/ regards, Mikey On 16 Jun 2010, at 21:38, Justin Anderson wrote: Also, I use different methods in my while loop: Cursor dbCursor; ... dbCursor.moveToFirst(); while (!dbCursor.isAfterLast()) { //do stuff dbCursor.moveToNext(); } -- 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 2:07 PM, Mikey frak@gmail.com wrote: 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 frak@gmail.com 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 ArrayListString fetchPermanent() { ArrayListString rows = new ArrayListString(); 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 android-beginners+unsubscr...@googlegroups.com 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 android-beginners+unsubscr...@googlegroups.com 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 android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -- You
Re: [android-beginners] Problem with cursors
So what is the error and where is it occurring? -- There are only 10 types of people in the world... Those who know binary and those who don't. -- On Fri, Jun 18, 2010 at 5:02 AM, Mikey frak@gmail.com wrote: Well, thanks - that seems to have done the trick, but now I am getting another error with another method - maybe you can tell me if you do things differently here as well? public boolean isPermanent(String screen_name) { boolean output = false; try { Cursor c = mDb.query(USERS, new String[] {CONSTANT}, SCREEN_NAME + =' + screen_name + ', null, null, null, null); if (c != null c.getCount() 0) { c.moveToFirst(); output = c.getString(0).contentEquals(C); c.close(); } } catch (Exception e) { Log.e(DBERR, e.getMessage()); } return output; } What is really annoying is that the exception is not caught in my handler, but in the System Daemon thread :o/ regards, Mikey On 16 Jun 2010, at 21:38, Justin Anderson wrote: Also, I use different methods in my while loop: Cursor dbCursor; ... dbCursor.moveToFirst(); while (!dbCursor.isAfterLast()) { //do stuff dbCursor.moveToNext(); } -- 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 2:07 PM, Mikey frak@gmail.com wrote: 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 frak@gmail.com 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 ArrayListString fetchPermanent() { ArrayListString rows = new ArrayListString(); 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 android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com 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 android-beginners+unsubscr...@googlegroups.com 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 android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com 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
Re: [android-beginners] Problem with cursors
The error is an IllegalStateException and as it is happening in this daemon thread I have no idea where it is occurring. It is very weird as my application has gone well past the point where it is using this query, and I have a breakpoint on the catch block that is not reached. Very confusing. On 18 Jun 2010, at 14:11, Justin Anderson wrote: So what is the error and where is it occurring? -- There are only 10 types of people in the world... Those who know binary and those who don't. -- On Fri, Jun 18, 2010 at 5:02 AM, Mikey frak@gmail.com wrote: Well, thanks - that seems to have done the trick, but now I am getting another error with another method - maybe you can tell me if you do things differently here as well? public boolean isPermanent(String screen_name) { boolean output = false; try { Cursor c = mDb.query(USERS, new String[] {CONSTANT}, SCREEN_NAME + =' + screen_name + ', null, null, null, null); if (c != null c.getCount() 0) { c.moveToFirst(); output = c.getString(0).contentEquals(C); c.close(); } } catch (Exception e) { Log.e(DBERR, e.getMessage()); } return output; } What is really annoying is that the exception is not caught in my handler, but in the System Daemon thread :o/ regards, Mikey On 16 Jun 2010, at 21:38, Justin Anderson wrote: Also, I use different methods in my while loop: Cursor dbCursor; ... dbCursor.moveToFirst(); while (!dbCursor.isAfterLast()) { //do stuff dbCursor.moveToNext(); } -- 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 2:07 PM, Mikey frak@gmail.com wrote: 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 frak@gmail.com 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 ArrayListString fetchPermanent() { ArrayListString rows = new ArrayListString(); 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 android-beginners+unsubscr...@googlegroups.com 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
Re: [android-beginners] Problem with cursors
Perhaps this will help: http://stackoverflow.com/questions/2398209/how-to-handle-in-code-illegalstateexception-on-cursor BTW, I fond this by googling Android IllegalStateException daemon -- There are only 10 types of people in the world... Those who know binary and those who don't. -- On Fri, Jun 18, 2010 at 7:15 AM, Mikey frak@gmail.com wrote: The error is an IllegalStateException and as it is happening in this daemon thread I have no idea where it is occurring. It is very weird as my application has gone well past the point where it is using this query, and I have a breakpoint on the catch block that is not reached. Very confusing. On 18 Jun 2010, at 14:11, Justin Anderson wrote: So what is the error and where is it occurring? -- There are only 10 types of people in the world... Those who know binary and those who don't. -- On Fri, Jun 18, 2010 at 5:02 AM, Mikey frak@gmail.com wrote: Well, thanks - that seems to have done the trick, but now I am getting another error with another method - maybe you can tell me if you do things differently here as well? public boolean isPermanent(String screen_name) { boolean output = false; try { Cursor c = mDb.query(USERS, new String[] {CONSTANT}, SCREEN_NAME + ='+ screen_name + ', null, null, null, null); if (c != null c.getCount() 0) { c.moveToFirst(); output = c.getString(0).contentEquals(C); c.close(); } } catch (Exception e) { Log.e(DBERR, e.getMessage()); } return output; } What is really annoying is that the exception is not caught in my handler, but in the System Daemon thread :o/ regards, Mikey On 16 Jun 2010, at 21:38, Justin Anderson wrote: Also, I use different methods in my while loop: Cursor dbCursor; ... dbCursor.moveToFirst(); while (!dbCursor.isAfterLast()) { //do stuff dbCursor.moveToNext(); } -- 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 2:07 PM, Mikey frak@gmail.com wrote: 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 frak@gmail.com 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 ArrayListString fetchPermanent() { ArrayListString rows = new ArrayListString(); 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 android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com 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
Re: [android-beginners] Problem with cursors
Thanks, I had already seen this article, but I am not really sure how I can call Activity methods in my DbAdapter, and I don't really want to return a cursor to my Activity - I just thought you may have some more magic code that would fix my problems ;o) I will let you know how I get on... On 18 Jun 2010, at 14:43, Justin Anderson wrote: Perhaps this will help: http://stackoverflow.com/questions/2398209/how-to-handle-in-code-illegalstateexception-on-cursor BTW, I fond this by googling Android IllegalStateException daemon -- There are only 10 types of people in the world... Those who know binary and those who don't. -- On Fri, Jun 18, 2010 at 7:15 AM, Mikey frak@gmail.com wrote: The error is an IllegalStateException and as it is happening in this daemon thread I have no idea where it is occurring. It is very weird as my application has gone well past the point where it is using this query, and I have a breakpoint on the catch block that is not reached. Very confusing. On 18 Jun 2010, at 14:11, Justin Anderson wrote: So what is the error and where is it occurring? -- There are only 10 types of people in the world... Those who know binary and those who don't. -- On Fri, Jun 18, 2010 at 5:02 AM, Mikey frak@gmail.com wrote: Well, thanks - that seems to have done the trick, but now I am getting another error with another method - maybe you can tell me if you do things differently here as well? public boolean isPermanent(String screen_name) { boolean output = false; try { Cursor c = mDb.query(USERS, new String[] {CONSTANT}, SCREEN_NAME + =' + screen_name + ', null, null, null, null); if (c != null c.getCount() 0) { c.moveToFirst(); output = c.getString(0).contentEquals(C); c.close(); } } catch (Exception e) { Log.e(DBERR, e.getMessage()); } return output; } What is really annoying is that the exception is not caught in my handler, but in the System Daemon thread :o/ regards, Mikey On 16 Jun 2010, at 21:38, Justin Anderson wrote: Also, I use different methods in my while loop: Cursor dbCursor; ... dbCursor.moveToFirst(); while (!dbCursor.isAfterLast()) { //do stuff dbCursor.moveToNext(); } -- 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 2:07 PM, Mikey frak@gmail.com wrote: 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 frak@gmail.com 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 ArrayListString fetchPermanent() { ArrayListString rows = new ArrayListString(); 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 =
Re: [android-beginners] Problem with cursors
Did this help? -- 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 2:38 PM, Justin Anderson janderson@gmail.comwrote: Also, I use different methods in my while loop: Cursor dbCursor; ... dbCursor.moveToFirst(); while (!dbCursor.isAfterLast()) { //do stuff dbCursor.moveToNext(); } -- 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 2:07 PM, Mikey frak@gmail.com wrote: 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 frak@gmail.com 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 ArrayListString fetchPermanent() { ArrayListString rows = new ArrayListString(); 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 android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com 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 android-beginners+unsubscr...@googlegroups.com 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 android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com 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 android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Problem with cursors
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 frak@gmail.com 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 ArrayListString fetchPermanent() { ArrayListString rows = new ArrayListString(); 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 android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com 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 android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Problem with cursors
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 frak@gmail.com 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 ArrayListString fetchPermanent() { ArrayListString rows = new ArrayListString(); 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 android-beginners+unsubscr...@googlegroups.com 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 android-beginners+unsubscr...@googlegroups.com 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 android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en
Re: [android-beginners] Problem with cursors
Also, I use different methods in my while loop: Cursor dbCursor; ... dbCursor.moveToFirst(); while (!dbCursor.isAfterLast()) { //do stuff dbCursor.moveToNext(); } -- 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 2:07 PM, Mikey frak@gmail.com wrote: 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 frak@gmail.com 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 ArrayListString fetchPermanent() { ArrayListString rows = new ArrayListString(); 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 android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com 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 android-beginners+unsubscr...@googlegroups.com 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 android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com 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 android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en