This is beacuse you probably forgot to close some Cursor object in your
project.
After you use a cursor, just write:
cursor.close();
Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[]
{ContactsContract.Contacts._ID,ContactsContract.Contacts.DISPLAY_NAME,ContactsContract.Contacts.HAS_PHONE_NUMBER};
String selection = ContactsContract.Contacts._ID+" = ?";
String[] selectionArgs = {Integer.toString(contactId)};
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE
LOCALIZED ASC";
Cursor cursor = act.managedQuery(uri, projection, selection, selectionArgs,
sortOrder);
while (cursor.moveToNext()) {
String name =
cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
String hasPhone =
cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
if (Integer.parseInt(hasPhone)!=0) {
//do something..
}
}
*cursor.close();*
cursor = null;
2011/7/8 slipp3ry <[email protected]>
> Please could anyone help before I grind what's left of my teeth away
> and pull what's left of my hair out.
>
> 07-08 14:54:58.623: INFO/dalvikvm(404): Uncaught exception thrown by
> finalizer (will be discarded):
> 07-08 14:54:58.623: INFO/dalvikvm(404): Ljava/lang/
> IllegalStateException;: Finalizing cursor
> android.database.sqlite.SQLiteCursor@4379a7d8 on activities that has
> not been deactivated or closed
> 07-08 14:54:58.623: INFO/dalvikvm(404): at
> android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
> 07-08 14:54:58.623: INFO/dalvikvm(404): at
> dalvik.system.NativeStart.run(Native Method)
>
> I ran into problems with my cursor handling on Honeycomb (fixed with
> stopManagingCursor always called at first point possible after
> startManagingCursor).
>
>
> I don't get any warnings or exceptions on Wildfire or any other
> emulators, just the 1.6 emulator.
>
> At some random point (even after closing the app) it chucks this up
> which makes it very difficult to pinpoint where the problem is.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en