public ArrayList<Info> queryDatabase(DatabaseHelper dbHelper,String table, String[] columns, String selection,
String[] selectionArgs, String groupBy, String having, String orderBy){
ArrayList<Info> infoList = new ArrayList<Info>();
db = dbHelper.getReadableDatabase();
Cursor cursor = db.query(table, columns, selection,
selectionArgs, groupBy, having, orderBy);
while(cursor.moveToNext()==true){
Info info = new Info();
info.id = Integer.valueOf(cursor.getString(cursor.getColumnIndex("id")));
info.accountname = cursor.getString(cursor.getColumnIndex("accountname"));
info.in_out = cursor.getString(cursor.getColumnIndex("in_out"));
info.logo = Integer.valueOf(cursor.getString(cursor.getColumnIndex("logo")));
info.moneys = cursor.getString(cursor.getColumnIndex("moneys"));
info.remark = cursor.getString(cursor.getColumnIndex("remark"));
info.sort = cursor.getString(cursor.getColumnIndex("sort"));
info.time = cursor.getString(cursor.getColumnIndex("time"));
info.user = cursor.getString(cursor.getColumnIndex("user"));
infoList.add(info);
}
cursor.close();
return infoList;
}
这个是我查询的方法,每查上3次log就会打出一堆error信息,应用还是可以继续查询的,没有影响,但老看着那些error就是不舒服,如果每次查询完都关闭数据库,效率上会不会降低很多?有别的方法解决吗
------解决方案--------------------
频繁的开关必定影像应用的性能,但是不关的话可能报错。可以把连续的数据库操作放到一起,然后关闭
------解决方案--------------------
一定要关闭。在模拟器中不会有影响,在真机中会崩溃
------解决方案--------------------
肯定得关撒,这是编程的习惯,否则可能会出现溢出的
------解决方案--------------------
楼主,不要犹豫了,肯定的关啊,不光是android是这样的,别的也是这样;
不关肯定会有异常的