Not closing cursor - only pre-Android 4.0?

I am testing an app on Android 4.0+ and it works great. On 2.2/2.3, I keep having issues with SQLlite cursors. The odd part if that this happens like 90% of the time when app starts. I can't explain why it sometimes work.

Here is partial LogCat:

05-01 20:02:30.341: E/Cursor(369): Finalizing a Cursor that has not been deactivated or closed. database = /data/data/com.---.---/databases/cats.db, table = trending_watching, query = SELECT _id, item_id, item, review, review_id, cat, user, url FROM trending_watching
05-01 20:02:30.341: E/Cursor(369): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here

Here is where problem happens:

In Splash Screen, I grab values from MySQL and put them in TWO different SQLlite Table. I can verify the table is being populated with data. Splash Screen exits.

The next Activity takes the two SQLLite Tables and gets the data like this:

    // Open Database

watchItemIdList = datasource
watchUsers = datasource
watchCats = datasource
watchReviews = datasource
watchReviewId = datasource
watchItems = datasource
watchUrl = datasource

     // Close database

It gets the data here:

public List<String> getWatchStrings(String dbColumn) {

    Cursor cursor = database.query(MySQLiteHelper.TABLE_WATCHING_REVIEWS,
            allTrendWatchingColumns, null, null, null, null, null);

    List<String> array = new ArrayList<String>();
    while (cursor.moveToNext()) {
        String uname = cursor.getString(cursor.getColumnIndex(dbColumn));
    return array;


The app keeps crashing, I believe from that LogCat on this line:

Cursor cursor = database.query(MySQLiteHelper.TABLE_WATCHING_REVIEWS,
            allTrendWatchingColumns, null, null, null, null, null);



just before You return, cursors have to be closed manually.

Need Your Help

getTargetFragment() returns null — works in one place but not another

android android-fragments android-listfragment android-dialogfragment

I am having an odd problem. I am implementing the same code in two places (both in ListFragments), but one works and the other throws a NullPointerException.

ASP.NET global resources issue

c# app-globalresources

I got an issue which already cost me some evenings to resolve.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.