I've a credit card applicatoin of which i've use database to place values on list view . After I run the application on emulator after merging it runs fine but crashes around the device when values begin placed the LogCat shows me the:close cursor however i have previously close all coursers that begin opened up. this the button action

plus.setOnClickListener(new View.OnClickListener() {


    public void onClick(View v) 
    {

        tx = txt.getText().toString();
        postive.add(tx);
        if(tx.length() >0)
        {
            myDB.execSQL("INSERT INTO UP (ID,UPNAME) VALUES ('"+idnum+"','"+tx+"')");

            txt.setText("");            
            function();
             results.clear();
            Intent i=new  Intent(Positive.this,NewgridActivity.class);
            bundle.putInt("tabid", 1);
            bundle.putInt("id", idnum);
            i.putExtras(bundle);
            startActivity(i);
            finish();
        }
        else
            DisplayToast("TextField Empty !!!!");

    }
});

any help please.

error in logcat

12-21 13:11:02.582: E/Database(4909): close() was never explicitly called on database '/data/data/pa.gd/databases/DECISION_GRID' 
12-21 13:11:02.582: E/Database(4909): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
12-21 13:11:02.582: E/Database(4909):   at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1810)
12-21 13:11:02.582: E/Database(4909):   at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:817)
12-21 13:11:02.582: E/Database(4909):   at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:851)
12-21 13:11:02.582: E/Database(4909):   at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:844)
12-21 13:11:02.582: E/Database(4909):   at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:540)
12-21 13:11:02.582: E/Database(4909):   at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
12-21 13:11:02.582: E/Database(4909):   at pa.gd.PAIDGRIDActivity.onCreate(PAIDGRIDActivity.java:66)
12-21 13:11:02.582: E/Database(4909):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-21 13:11:02.582: E/Database(4909):   at dalvik.system.NativeStart.main(Native Method)

log error afer closing database

i've close the db after i then consider adding i something it crashes with this particular log error

12-21 15:45:58.043: E/AndroidRuntime(401): FATAL EXCEPTION: main
12-21 15:45:58.043: E/AndroidRuntime(401): java.lang.IllegalStateException: database not open
12-21 15:45:58.043: E/AndroidRuntime(401):  at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1723)
12-21 15:45:58.043: E/AndroidRuntime(401):  at dc.grd.Positive$1.onClick(Positive.java:77)
12-21 15:45:58.043: E/AndroidRuntime(401):  at android.view.View.performClick(View.java:2408)
12-21 15:45:58.043: E/AndroidRuntime(401):  at android.view.View$PerformClick.run(View.java:8816)
12-21 15:45:58.043: E/AndroidRuntime(401):  at android.os.Handler.handleCallback(Handler.java:587)
12-21 15:45:58.043: E/AndroidRuntime(401):  at android.os.Handler.dispatchMessage(Handler.java:92)
12-21 15:45:58.043: E/AndroidRuntime(401):  at android.os.Looper.loop(Looper.java:123)
12-21 15:45:58.043: E/AndroidRuntime(401):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-21 15:45:58.043: E/AndroidRuntime(401):  at java.lang.reflect.Method.invokeNative(Native Method)
12-21 15:45:58.043: E/AndroidRuntime(401):  at java.lang.reflect.Method.invoke(Method.java:521)
12-21 15:45:58.043: E/AndroidRuntime(401):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-21 15:45:58.043: E/AndroidRuntime(401):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-21 15:45:58.043: E/AndroidRuntime(401):  at dalvik.system.NativeStart.main(Native Method)

You appear to become using myDB for the database object. For the reason that situation make use of this to shut it: myDB.close(). – Sander van't Veer <

  1. myDB.close() the answer give by Sander Vant Veer labored

Consider a existence cycle for you personally database connection. I suggest to spread out the db inside your application class or perhaps in the onResume() approach to your activity. Close the db in onPause().

Whenever you train with the database, make certain that cursors are properly closed once you are done dealing with it.

And incidentally: Any time you write an issue title as if you did, a kitten dies...