Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8791583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:51:47+00:00 2026-06-13T22:51:47+00:00

I have get Exception after succesfylly fetching data.I have cursor close . Exception- 11-06

  • 0

I have get Exception after succesfylly fetching data.I have cursor close.

Exception-

11-06 14:31:09.942: I/dalvikvm(598): Uncaught exception thrown by finalizer (will be discarded):
11-06 14:31:09.942: I/dalvikvm(598): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@44c115b8 on null that has not been deactivated or closed
11-06 14:31:09.942: I/dalvikvm(598):    at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
11-06 14:31:09.942: I/dalvikvm(598):    at dalvik.system.NativeStart.run(Native Method)
11-06 14:31:09.942: I/dalvikvm(598): Uncaught exception thrown by finalizer (will be discarded):
11-06 14:31:09.942: I/dalvikvm(598): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@44c10768 on null that has not been deactivated or closed
11-06 14:31:09.942: I/dalvikvm(598):    at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
11-06 14:31:09.942: I/dalvikvm(598):    at dalvik.system.NativeStart.run(Native Method)
11-06 14:31:09.942: I/dalvikvm(598): Uncaught exception thrown by finalizer (will be discarded):
11-06 14:31:09.942: I/dalvikvm(598): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@44c0f918 on null that has not been deactivated or closed
11-06 14:31:09.942: I/dalvikvm(598):    at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
11-06 14:31:09.942: I/dalvikvm(598):    at dalvik.system.NativeStart.run(Native Method)
11-06 14:31:09.942: I/dalvikvm(598): Uncaught exception thrown by finalizer (will be discarded):
11-06 14:31:09.942: I/dalvikvm(598): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@44c0df08 on null that has not been deactivated or closed
11-06 14:31:09.942: I/dalvikvm(598):    at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
11-06 14:31:09.942: I/dalvikvm(598):    at dalvik.system.NativeStart.run(Native Method)
11-06 14:31:09.942: I/dalvikvm(598): Uncaught exception thrown by finalizer (will be discarded):
11-06 14:31:09.942: I/dalvikvm(598): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@44c0c990 on null that has not been deactivated or closed
11-06 14:31:09.942: I/dalvikvm(598):    at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
11-06 14:31:09.942: I/dalvikvm(598):    at dalvik.system.NativeStart.run(Native Method)

Sql Statements

           String tableName="StateList_Tbl";
         String databaseName="TravelguideDb";
         int databaseVersion=3;

         assetDatabaseHelper=new AssetDatabaseOpenHelper(HomeScreen.this, databaseName,databaseVersion);
         assetDatabaseHelper.openDatabase();
         assetDatabaseHelper.openReadableMode();
         groupEntityList=new ArrayList<GroupEntity>();



        String selectQuery = "SELECT State_id,State_name FROM " +tableName +" where country_part=36";


       groupCursor=assetDatabaseHelper.executeQuery(selectQuery);

        if (groupCursor.moveToFirst()) 
        {
                 do {
                     groupEntityObj=new GroupEntity();
                     groupEntityObj.setGroupId(groupCursor.getInt(0));
                     System.out.println("stateid"+groupCursor.getInt(0));
                     groupEntityObj.setGroupName(groupCursor.getString(1));
                     System.out.println("stateid"+groupCursor.getString(1));
                    String stateQuery="SELECT State_id,State_name FROM " +tableName +" where country_part="+groupCursor.getInt(0);
                    stateCursor=assetDatabaseHelper.executeQuery(stateQuery);
                    stateArrayList=new ArrayList<StateMetaData>();
                    if(stateCursor.moveToFirst())
                    {
                        do{
                         stateMetaDataObj=new StateMetaData();
                         stateMetaDataObj.setStateId(stateCursor.getInt(0));
                         System.out.println("stateid"+stateCursor.getInt(0));
                         stateMetaDataObj.setStateName(stateCursor.getString(1));
                         System.out.println("stateid"+stateCursor.getString(1));
                         stateArrayList.add(stateMetaDataObj);

                        }while(stateCursor.moveToNext());
                    }


                    groupEntityObj.setStatesList(stateArrayList);

                    groupEntityList.add(groupEntityObj);
                 } while (groupCursor.moveToNext());

        }

        System.out.println("gr "+groupEntityList.size());
        stateCursor.close();
        groupCursor.close();
        assetDatabaseHelper.close();

        System.out.println("cursor"+stateCursor.getColumnCount());
        System.out.println("cursor"+groupCursor);

AssetDatabaseOpenHelper class

 public class AssetDatabaseOpenHelper {
    private Context context;
    private SQLiteDatabase sqliteDatabaseObj;
    private String database_name;
    private CreateQueries createQueriesObj;
    private MySQLiteHelper mySQLitehelperObj;
    private int database_version;

    private  String databaseName="TravelguideDb";
    private  int databaseVersion=3;
    public AssetDatabaseOpenHelper(Context context,String databaseName,int database_version) {
        this.context = context;
        this.database_name=databaseName;
        this.database_version=database_version;
    }



    public AssetDatabaseOpenHelper(Context context) {

        this.context = context;
        this.database_name = databaseName;
        this.database_version = databaseVersion;
    }



    public void openDatabase() {
        mySQLitehelperObj = new MySQLiteHelper(context, database_name,
                database_version);

        File dbFile = context.getDatabasePath(database_name);
System.out.println("Assests"+dbFile.exists());
        if (!dbFile.exists()) {
            try {
                copyDatabase(dbFile);
            } catch (IOException e) {
            throw new RuntimeException("Error creating source database", e);
            //  e.printStackTrace();
            }
        }
 //  sqliteDatabaseObj= SQLiteDatabase.openDatabase(dbFile.getPath(), null, SQLiteDatabase.OPEN_READONLY);
//        sqliteDatabaseObj = mySQLitehelperObj.getReadableDatabase();

    }
public void openReadableMode()
{
     sqliteDatabaseObj = mySQLitehelperObj.getReadableDatabase();
}
public void openWriteableMode()
{
     sqliteDatabaseObj = mySQLitehelperObj.getWritableDatabase();
}
public void close() {

    mySQLitehelperObj.close();
}

    private void copyDatabase(File dbFile) throws IOException {

        OutputStream os = new FileOutputStream(dbFile);

        InputStream is = null;
        byte[] buffer = new byte[1024];
        for(int i=1;i<5;i++)
        {
       is = context.getAssets().open("TravelguideDb.sqlite.00"+1);
         int length;
        while ((length=is.read(buffer))!=-1) {
            os.write(buffer,0,length);
        }
        is.close();
    }

        os.flush();
        os.close();
        is.close();
    }

   public Cursor executeQuery(String query)
   {
     Cursor outputCursor=  sqliteDatabaseObj.rawQuery(query, null);
    return outputCursor;
   }
    public void createTable(String tableName, String[] columns, String[] value) {
        createQueriesObj = new CreateQueries();
        String createTableQuery = createQueriesObj.CreateTableQuery(tableName,
                columns, value);
        sqliteDatabaseObj.execSQL(createTableQuery);
        System.out.println("Query" + createTableQuery);
    }
    public void deleteTable(String tableName) 
    {
        sqliteDatabaseObj.execSQL("Drop table " + tableName);
    }

    public void deleteAllDataFromTable(String tableName) {
        // truncate table
        sqliteDatabaseObj.delete(tableName, null, null);
    }
    public void deletePerticularRows(String tableName, String whereClause,
            String[] whereArgs) {
        sqliteDatabaseObj.delete(tableName, whereClause, whereArgs);
    }

    public Cursor fetchAllRows(String tableName) {

        return sqliteDatabaseObj.query(tableName, null, null, null, null, null,
                null);
    }
    public Cursor selectOnWhereCondition(String tableName,
            String[] columnsToSelect, String whereColumnName,
            String[] whereEqualsTo, String groupBy, String having,
            String orderBy) {
        return sqliteDatabaseObj.query(tableName, columnsToSelect,
                whereColumnName, whereEqualsTo, groupBy, having, orderBy);
    }




}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:51:47+00:00Added an answer on June 13, 2026 at 10:51 pm

    You are accessing cursors for log messages after they have been closed.

    To ensure proper closing, use cursors like this:

        Cursor c = DB.rawQuery(queryString);
        try{    
            while(c.moveToNext()){
    
               Cursor c2 = DB.rawQuery(queryString2);
               try{
                   while(c2.moveToNext()){                 
                   //--do stuff---
                   }
    
               } finally {
                   c2.close();
               }
    
            }
        }finally {
            c.close();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get exception of page load, but still have not results on
why do I get this exception?please suggest any solutions.i have properly copied mail.jar and
when i run my application, i get following exception. I have no problem with
I have a C# application..I continuously get a null reference exception..I manage to catch
So I have a class that has the following member variables. I have get
Suppose I was given a URL. It might already have GET parameters (e.g. http://example.com/search?q=question
<div id=container1> <span>...</span> </div> <div id=container2> <span>...</span> </div> Say if I have get the
I have to get the sub total of time spent in SQL any ideas?
I have to get a part of my content provider query in a String[]
I have to get a date from a string. So I am using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.