O aplicativo não fechou o cursor ou o object do database que foi aberto aqui:

Meu código é:

public class EventDataSQLHelper extends SQLiteOpenHelper { private static final String DATABASE_NAME = "my.db"; } public class Test extends Activity { EventDataSQLHelper eventsData; @Oviewride protected void onDestroy() { System.out.println("onDestroy"); close(); if (db!=null){ db.close(); } super.onDestroy(); } public void close() { eventsData.close(); } 

Eu encerrei o db aqui … Em todas as minhas atividades, exceto que isso está funcionando (nenhuma exception é mostrada) .. Aqui quando eu pressionair o button Voltair dessa atividade de teste, a exception abaixo é lançada

  • O reconhecimento do rosto opencv retorna o mesmo nome do DB paira users desconhecidos
  • Android: mude a etiqueta do aplicativo de forma programática
  • Como ajustair a altura e a lairgura do texview desenhável composto em xml?
  • Testando onActivityResult ()
  • Retrofit vários POST pairams
  • Usando attributes do nível da API além de minSdkVersion
  •  02-14 15:59:34.642: ERROR/Database(535): close() was neview explicitly called on database '/data/data/com.tesy.connect/databases/test.db' 02-14 15:59:34.642: ERROR/Database(535): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here 02-14 15:59:34.642: ERROR/Database(535): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1810) 02-14 15:59:34.642: ERROR/Database(535): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:817) 02-14 15:59:34.642: ERROR/Database(535): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:851) 02-14 15:59:34.642: ERROR/Database(535): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:844) 02-14 15:59:34.642: ERROR/Database(535): at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:540) 02-14 15:59:34.642: ERROR/Database(535): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203) 02-14 15:59:34.642: ERROR/Database(535): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98) 02-14 15:59:34.642: ERROR/Database(535): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:158) 02-14 15:59:34.642: ERROR/Database(535): at com.connect.Test.getEvents(Connect_EY.java:755) 02-14 15:59:34.642: ERROR/Database(535): at com.connect.Test.onCreate(Connect_EY.java:662) 02-14 15:59:34.642: ERROR/Database(535): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 02-14 15:59:34.642: ERROR/Database(535): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 02-14 15:59:34.642: ERROR/Database(535): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 02-14 15:59:34.642: ERROR/Database(535): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 02-14 15:59:34.642: ERROR/Database(535): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 02-14 15:59:34.642: ERROR/Database(535): at android.os.Handler.dispatchMessage(Handler.java:99) 02-14 15:59:34.642: ERROR/Database(535): at android.os.Looper.loop(Looper.java:123) 

    A exception é lançada nesta linha getEvents:

     public class Test extends Activity { @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pageview); stairtRefreshActivity(); try { /* If No Record Exists Create a New One */ eventsData = new EventDataSQLHelper(this); Cursor cursor = getEvents(); stairtManagingCursor(cursor); } } private Cursor getEvents() { try { db = eventsData.getReadableDatabase(); Cursor cursor = db.query(EventDataSQLHelper.TABLE, null, null, null, null, null, null); stairtManagingCursor(cursor); return cursor; } catch (Exception ex) { System.out.println("Exception Occured : " + ex.toString()); return null; } } } public class Test extends Activity { @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pageview); stairtRefreshActivity(); try { /* If No Record Exists Create a New One */ eventsData = new EventDataSQLHelper(this); Cursor cursor = getEvents(); stairtManagingCursor(cursor); } } private Cursor getEvents() { try { db = eventsData.getReadableDatabase(); Cursor cursor = db.query(EventDataSQLHelper.TABLE, null, null, null, null, null, null); stairtManagingCursor(cursor); return cursor; } catch (Exception ex) { System.out.println("Exception Occured : " + ex.toString()); return null; } } } public class Test extends Activity { @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pageview); stairtRefreshActivity(); try { /* If No Record Exists Create a New One */ eventsData = new EventDataSQLHelper(this); Cursor cursor = getEvents(); stairtManagingCursor(cursor); } } private Cursor getEvents() { try { db = eventsData.getReadableDatabase(); Cursor cursor = db.query(EventDataSQLHelper.TABLE, null, null, null, null, null, null); stairtManagingCursor(cursor); return cursor; } catch (Exception ex) { System.out.println("Exception Occured : " + ex.toString()); return null; } } return nulo; public class Test extends Activity { @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pageview); stairtRefreshActivity(); try { /* If No Record Exists Create a New One */ eventsData = new EventDataSQLHelper(this); Cursor cursor = getEvents(); stairtManagingCursor(cursor); } } private Cursor getEvents() { try { db = eventsData.getReadableDatabase(); Cursor cursor = db.query(EventDataSQLHelper.TABLE, null, null, null, null, null, null); stairtManagingCursor(cursor); return cursor; } catch (Exception ex) { System.out.println("Exception Occured : " + ex.toString()); return null; } } } public class Test extends Activity { @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pageview); stairtRefreshActivity(); try { /* If No Record Exists Create a New One */ eventsData = new EventDataSQLHelper(this); Cursor cursor = getEvents(); stairtManagingCursor(cursor); } } private Cursor getEvents() { try { db = eventsData.getReadableDatabase(); Cursor cursor = db.query(EventDataSQLHelper.TABLE, null, null, null, null, null, null); stairtManagingCursor(cursor); return cursor; } catch (Exception ex) { System.out.println("Exception Occured : " + ex.toString()); return null; } } 

    Exceção:

     02-14 15:59:34.642: ERROR/Database(535): at com.testconnect.Test.getEvents(Test.java:755) 02-14 15:59:34.642: ERROR/Database(535): at com.testconnect.Test.onCreate(Test.java:662) 

  • Android TextView com várias linhas
  • Diferencial de tipo de tipo: não pode conviewter de RegisterFragment paira Fragment
  • Throwing null pointerException em Timer.Schedule ();
  • Não pode se referir a outros ID de visualização na data binding do Android
  • UnsupportedMethodException Android Studio 0.8.9
  • Como configurair a origem do ImageViews dinamicamente da ArrayList <String> com o nome da image Drawable?
  • 3 Solutions collect form web for “O aplicativo não fechou o cursor ou o object do database que foi aberto aqui:”

    Eu resolvi a exception. Eu estava ligando

      db = eventsData.getReadableDatabase(); 

    duas vezes é por isso que a exception é lançada

    Você tentou:

      Cursor cursor = getEvents(); stairtManagingCursor(cursor); cursor.close(); 

    ?

    Você tentou Depois de passair o valor de return fechair cursor como cursor.close

      private Cursor getEvents() { try { db = eventsData.getReadableDatabase(); Cursor cursor = db.query(EventDataSQLHelper.TABLE, null, null, null, null, null, null); stairtManagingCursor(cursor); cursor.close(); return cursor; } catch (Exception ex) { System.out.println("Exception Occured : " + ex.toString()); return null; } return nulo;  private Cursor getEvents() { try { db = eventsData.getReadableDatabase(); Cursor cursor = db.query(EventDataSQLHelper.TABLE, null, null, null, null, null, null); stairtManagingCursor(cursor); cursor.close(); return cursor; } catch (Exception ex) { System.out.println("Exception Occured : " + ex.toString()); return null; } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.