htcdesireportal


HTC Desire Dev Tipp – managedQuery

This item was filled under [ Dev Tipps, Guides ]

Many of you are probably developing for Android. Some commercially some just for fun. However, I recently came across a little, but important mistake some tutorials inherit when it’s about Content Providers using SQLite. There are several methods to query your database but one seems especially easy  to use: it’s the managedQuery -Method. Although it is listed as deprecated it’s pretty popular. However, usually you have to use close(). This is not true for a Cursor which got returned by a managedQuery. It will cause a ANR (Application Not Responding) Error, which results in a crashed application. It is already named managedQuery, it manages its lifecycle on its own. All other Cursors need to be closed, e.g. in onDestroy().
Closing the managedQuery-Cursor will result in crashing the Application on Honeycomb (or later) devices.

I hope I could help!

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
2416
HTC Desire Hd
Nullam elementum massa diam, a porttitor arcu. Suspendisse potenti. Donec euismod sollicitudin ipsum ac feugiat. Sed et nulla arcu, a tempus est. Etiam vel laoreet nunc. In lobortis, lacus non vehicula hendrerit, nisi dolor rutrum metus, ac pulvinar purus lacus a urna. Praesent consequat dignissim ligula vitae scelerisque.