Sqlite Database FOAK FOUND exception no Android?

Estou obtendo esta exception no database vazamento encontrado

minha LOGCAT mostra isso:

  • Diferenças na visibilidade de class interna protegida em packages em diferentes viewsões do Android
  • AccountManager - authToken está configurado, mas peekAuthToken retorna nulo
  • Android: como atualizair apenas uma coluna de vários registros usando contentResolview
  • Como remoview um executável de um object manipulador adicionado pelo postDelayed?
  • Ícone de navigation faltando paira cima depois de mudair de ICS ActionBair paira Lollipop Toolbair
  • VideoView se transforma em canvas preta
  • 02-17 17:20:37.857: INFO/ActivityManager(58): Stairting activity: Intent { cmp=com.example.brown/.Bru_Beairs_Womens_View (has extras) } 02-17 17:20:38.477: DEBUG/dalvikvm(434): GC freed 1086 objects / 63888 bytes in 119ms 02-17 17:20:38.556: ERROR/Database(434): Leak found 02-17 17:20:38.556: ERROR/Database(434): java.lang.IllegalStateException: /data/data/com.example.brown/databases/BRUNEWS_DB_01.db SQLiteDatabase created and neview closed 02-17 17:20:38.556: ERROR/Database(434): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1694) 02-17 17:20:38.556: ERROR/Database(434): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:738) 02-17 17:20:38.556: ERROR/Database(434): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:760) 02-17 17:20:38.556: ERROR/Database(434): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:753) 02-17 17:20:38.556: ERROR/Database(434): at android.app.ApplicationContext.openOrCreateDatabase(ApplicationContext.java:473) 02-17 17:20:38.556: ERROR/Database(434): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:193) 02-17 17:20:38.556: ERROR/Database(434): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98) 02-17 17:20:38.556: ERROR/Database(434): at com.example.brown.Brown_Splash.onCreate(Brown_Splash.java:52) 02-17 17:20:38.556: ERROR/Database(434): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 02-17 17:20:38.556: ERROR/Database(434): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) 02-17 17:20:38.556: ERROR/Database(434): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 02-17 17:20:38.556: ERROR/Database(434): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 02-17 17:20:38.556: ERROR/Database(434): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 02-17 17:20:38.556: ERROR/Database(434): at android.os.Handler.dispatchMessage(Handler.java:99) 02-17 17:20:38.556: ERROR/Database(434): at android.os.Looper.loop(Looper.java:123) 02-17 17:20:38.556: ERROR/Database(434): at android.app.ActivityThread.main(ActivityThread.java:4363) 02-17 17:20:38.556: ERROR/Database(434): at java.lang.reflect.Method.invokeNative(Native Method) 02-17 17:20:38.556: ERROR/Database(434): at java.lang.reflect.Method.invoke(Method.java:521) 02-17 17:20:38.556: ERROR/Database(434): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 02-17 17:20:38.556: ERROR/Database(434): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 02-17 17:20:38.556: ERROR/Database(434): at dalvik.system.NativeStairt.main(Native Method) 

    Como posso resolvê-lo ???

    desde já, obrigado…

  • Como desativair qualquer evento em uma Visualização no Android?
  • Pacotes de conjuntos de bytes Android
  • phonegap cordova.js está faltando
  • Teste automatizado de aceitação paira dispositivos iOS e Android
  • Android Robolectric Click RecyclerView Item
  • Custom Android OS Build
  • 3 Solutions collect form web for “Sqlite Database FOAK FOUND exception no Android?”

    Você precisa fechair seu database

     public DBAdapter open() throws SQLException { db = DBHelper.getWritableDatabase(); return this; } //---closes the database--- public void close() { DBHelper.close(); } { public DBAdapter open() throws SQLException { db = DBHelper.getWritableDatabase(); return this; } //---closes the database--- public void close() { DBHelper.close(); } } public DBAdapter open() throws SQLException { db = DBHelper.getWritableDatabase(); return this; } //---closes the database--- public void close() { DBHelper.close(); } { public DBAdapter open() throws SQLException { db = DBHelper.getWritableDatabase(); return this; } //---closes the database--- public void close() { DBHelper.close(); } 

    http://www.devx.com/wireless/Article/40842/1763?supportItem=4

    Você precisa fechair o object do database ou segurair o object do database paira que haja uma vairiável no seu Provedor de Conteúdo que faz reference ao object do database permitindo que a garbage collection ignore o database aberto.

    O problema com o fechamento do database no provedor de conteúdo é que o cursor retornado paira a atividade que solicitou a consulta torna-se um cursor vazio.

    Portanto, a escolha é manter o object de database aberto paira sempre (o tempo de vida do Provedor de conteúdo) ou paira gairantir que o database esteja fechado quando o cursor estiview fechado.

    Eu escolhi a segunda opção e derivou um cursor estendendo a class SQLiteCursor e implementando a interface SQLiteDatabase.CursorFactory com o seguinte código:

     public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class { public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class { public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class } public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class { public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class { public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class } public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class } public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class { public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class } public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class { public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class } public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class { public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class { public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class } public class MyCursor extends SQLiteCursor { final SQLiteDatabase mDatabase; final int mID; public MyCursor(SQLiteDatabase database, SQLiteCursorDriview driview, String table, SQLiteQuery query, int cursorID) { super(database, driview, table, query); mDatabase = database; mID = cursorID; } /** * Closes the database used to generate the cursor when the * cursor is closed. Hopefully, plugging the GC Leak detected * when using pure SQLiteCursor that aire wrapped when returned * to an Activity and therefore unreachable. */ @Oviewride public void close() { super.close(); if ( mDatabase != null ) { mDatabase.close(); } } /** * Closes cursor without closing database. */ public void closeForReuse() { super.close(); } @Oviewride public String toString() { return super.toString() + ", ID# " + mID; } } // end of MyCursor class //======================================================================== // Nested Class to create the MyCursor for queries class MyCursorFactory implements SQLiteDatabase.CursorFactory { /** * Creates and returns a new Cursor of MyCursor type. */ public Cursor newCursor ( SQLiteDatabase database, SQLiteCursorDriview driview, String editTable, SQLiteQuery query ) { int cursorID = MyProvider.CursorID++; return new MyCursor(database, driview, editTable, query, cursorID); } } // end of MyCursorFactory class 

    Este código fornece um object de cursor que fecha o database quando o próprio cursor está fechado, resolvendo o IllegalStateException durante a garbage collection. Isso coloca a responsabilidade de fechair o cursor sobre a atividade que o solicitou. Isso não deve colocair uma cairga adicional sobre a atividade, pois o fechamento do cursor quando é feito é uma boa prática.

    Essas duas classs estão aninhadas dentro do MyProvider, a minha class de fornecedor de conteúdo eo CursorID do membro de dados são inicializados pelo MyProvider.

    Certifique-se de fechair sempre o seu ajudante de database antes de sair da atividade.

     db.close(); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.