最近我开始在我的应用程序中出现以下错误。这不在任何特定的地方,只有在循环所有数据读/写功能时我才能重现。它几乎出现在任何地方。
09-14 08:52:15.089: WARN/SQLiteConnectionPool(19268): The connection pool for database '/data/data/com.nnn/databases/data.db' has been unable to grant a connection to thread 1 (main) with flags 0x5 for 30.000002 seconds.
Connections: 0 active, 1 idle, 0 available.
有没有办法避免这种情况?我知道不知何故我用尽了与数据库的所有连接?我正在使用方法#1:http ://www.androiddesignpatterns.com/2012/05/correctly-managing-your-sqlite-database.html
我的数据库代码如下所示:
public class DatabaseHelper extends SQLiteOpenHelper
{
private final static String LOG_TAG = "com.nnnn.data.DatabaseHelper";
private static final String DATABASE_NAME = "data.db";
private static final int DATABASE_VERSION = 260;
private static SQLiteDatabase databaseInstance;
public DatabaseHelper()
{
super(MyApplication.Me, DATABASE_NAME, null, DATABASE_VERSION);
}
public static synchronized SQLiteDatabase getDatabase()
{
if (databaseInstance == null) databaseInstance = (new DatabaseHelper()).getWritableDatabase();
return databaseInstance;
}