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 7069585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:27:48+00:00 2026-05-28T05:27:48+00:00

Okay, i am new for android developping, or any developping and getting this error.

  • 0

Okay, i am new for android developping, or any developping and getting this error. I am trying to do is everytime user select a spinner item then program creates a list. I have an DatabaseHelper class that i am using for getting results of the list. But the problem is it is never create a list, and it gives this error.

DatabaseHelper Methods that activity uses;

 public int[] searchbyLetter(String letter) {
    // TODO Auto-generated method stub
    int[] results = new int[100];
    int count = 0;

    String[] columns = new String[] { KEY_MINERALID };
    Cursor c = minerals.query(DATABASE_TABLE, columns, KEY_LETTER + "= '"
            + letter + "'", null, null, null, null);
    if (c.moveToFirst()) {
        results[count] = c.getInt(c.getColumnIndex(KEY_MINERALID));
    }

    while (c.moveToNext()) {
        count++;
        results[count] = c.getInt(c.getColumnIndex(KEY_MINERALID));
    }
    c.close();
    return results;
}

 public String getName(int _id) {
    // TODO Auto-generated method stub
    String[] columns = new String[] { KEY_NAME };
    Cursor c = minerals.query(DATABASE_TABLE, columns, KEY_MINERALID + "="
            + _id, null, null, null, null);
    c.moveToFirst();
    int iName = c.getColumnIndex(KEY_NAME);
    String result = c.getString(iName);
    c.close();
    return result;
}

This my ListActivity class;

public class Az extends ListActivity {

String[] spAzPaht = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
        "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
        "Y", "Z" };
ArrayList<AzOrder> azOrder;
AzOrderAdapter azOrderAdapter;
Spinner spAZ;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.az);
    ArrayAdapter<String> spAzAdpt = new ArrayAdapter<String>(Az.this,
            android.R.layout.simple_spinner_item, spAzPaht);

    spAZ = (Spinner) findViewById(R.id.spAZ);
    spAZ.setAdapter(spAzAdpt);
    azOrder = new ArrayList<AzOrder>();
    this.azOrderAdapter = new AzOrderAdapter(Az.this, R.layout.az, azOrder);
    setListAdapter(azOrderAdapter);

    spAZ.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) {

            getSearches();

        }

        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

            getSearches();

        }
    });

}


private void getSearches() {
    DatabaseHelper myDBHelper = new DatabaseHelper(Az.this);

    try {
        myDBHelper.createDataBase();
    } catch (IOException e) {
        // TODO: handle exception
        e.printStackTrace();
    }
    try {
        myDBHelper.openDataBase();
    } catch (SQLException sqle) {
        throw sqle;
        // TODO: handle exception
    }
    int position = spAZ.getSelectedItemPosition();
    String letter = spAzPaht[position];
    int[] results = myDBHelper.searchbyLetter(letter);

    try {

        azOrder = new ArrayList<AzOrder>();
        AzOrder AZO = new AzOrder();
        for (int i = 0; i < results.length; i++) {
            AZO.setName(myDBHelper.getName(results[i]));
            AZO.setMineral_ID(results[i]);
            azOrder.add(AZO);
        }
        Thread.sleep(5000);
        Log.i("Array", "" + azOrder.size());
    } catch (Exception e) {
        // TODO: handle exception
        Log.e("BACKGROUND_PROC", e.getMessage());
    }
    myDBHelper.close();


}

This is the error that i am getting

    E/Cursor(295): Finalizing a Cursor that has not been deactivated or 
    closed. database = /data/data/com.mineralidentifier.degosa.test1/databases/
    minerals, table = minerals, query = SELECT minerals_name FROM minerals 
    WHERE _id=0

    E/Cursor(295): android.database.sqlite.DatabaseObjectNotClosedException: 
    Application did not close the cursor or database object that was opened 
    here

    E/Cursor(295):  at android.database.sqlite.SQLiteCursor.<init>
    (SQLiteCursor.java:210)

    E/Cursor(295):  at android.database.sqlite.SQLiteDirectCursorDriver.query
    (SQLiteDirectCursorDriver.java:53)
  • 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-05-28T05:27:49+00:00Added an answer on May 28, 2026 at 5:27 am

    Looks like the Cursor isn’t being closed. I see you have the c.close(), but might not reach it because another exception is being thrown before it. And, that exception is being masked by the DatabaseObjectNotClosedException ends up being thrown masking the original one. It’s best to wrap that in a finally clause to ensure it always is closed regardless of an exception being thrown or not.

    Cursor c = ...
    try {
       ...
    } finally {
       c.close();
    }
    

    If you do that then it may tell you what the real problem is. Unfortunately, since we don’t see the full exception’s stacktrace we can’t see where exactly DatabaseObjectNotClosedException is thrown from in your code. We can only see where in the android code it’s thrown from, but we can’t see past SQLiteDirectCursorDriver.query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Or is it okay to do something like this: new Thread( new ThreadStart( delegate
Okay this is my 4th question today on Scheme, still pretty new to Scheme,
Okay I have updated my code quite a bit. I am getting a new
fairly new to Android development. I made a function for the user to call
Okay, so, I am making a Tumblr client for Android, I've been trying and
I'm new to android but I've done the notepad tutorial. Now I'm trying to
Okay I;m really new to VB.NET and desktop application development. Simplified this is what
Okay so I have started a new language in class. We are learning Scheme
Okay so I'm kind of new with OpenGL, but I thought I should learn
Okay, so I'm pretty new to xcode but I cannot find something specific to

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.