我有我的数据库连接设置中的应用程序,但logcat的保持的向我讲述了一个SQLite泄漏的Android SQLite的泄露错误
04-25 11:22:23.771: W/SQLiteConnectionPool(9484): A SQLiteConnection object for database '+data+data+com_appstart+databases+database' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
我开始怀疑是否是到我如何使用数据库适配器。 我附上我的代码... 这是我的代码,其中一些时间,我发现错..
try{
DBAdapter dba = new DBAdapter(this);
dba.open();
Cursor c = dba.getModules(Constant.LANGUAGE_ID);
for (int i = 0; i < c.getCount(); i++) {
if (i > 2) {
a.add(c.getString(2));
moduleid.add(c.getString(0));
icon_name.add(c.getString(1));
System.out.println(c.getString(2) + "------" + c.getString(0));
}
c.moveToNext();
}
c.close();
dba.close();
}catch(Exception e){
e.printStackTrace();
}
这是我将对DBAdapter类,它包含open()和关闭()方法。
public DBAdapter open() throws SQLException {
db = DBHelper.getWritableDatabase();
return this;
}
public void close() {
DBHelper.close();
}
我使用DBAdapter类进行数据库连接,并且此类包含Close和Open方法。所以,当我需要任何数据库表我打开这adpater,并在我用我关闭此adapter.but后有时我得到这个错误,没有数据会被发现。 – 2013-04-25 06:05:35
确保您关闭所有打开的数据库?否则您发布您的代码我可以检查它,如果可能,我会帮你.. – Subburaj 2013-04-25 06:07:26
等一分钟我发布我的代码... – 2013-04-25 06:08:04