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 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
>>> android-beginners+unsubscr...@googlegroups.com<android-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.com<android-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.com<android-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

Reply via email to