Application stopped in Android / SQLITE ERROR /

Yesterday the application worked fine, and I did not edit my codes. But now it does not work. logcat

close() was never explicitly called on database '/data/data/[myproject]/databases/MyDB' 
android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1943)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1007)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:986)
at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1051)
at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:770)
at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:157)
at mn.emondo.parliament.DBAdapter.open(DBAdapter.java:46)
at mn.emondo.parliament.ProfileActivity.onCreate(ProfileActivity.java:46)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
+5
source share
5 answers

After opening the database and cursor, you must close these two before exiting the class or action. db.close (); cr.close ();

use this.

+2
source

You did not close the cursor. It is written in your ERROR.

Application did not close the cursor or database object that was opened here

Since I do not see your code, just make sure that you have not closed your Cursor.

Or try to clean the project and rebuild it.

+1
source

close() ; DatabaseObjectNotClosedException.

+1

, ,,

, .

+1

Try this method when you are finished receiving data from the database.
When you open the database, you need to call db.open (), and when you finish working with the database, you need to call the close () method. using the following method.

db.close();

and you have to call to open the database from Activity.java

+1
source

All Articles