03-12 14:17:00.954: W/SQLiteCompiledSql(3198): Releasing statement in a finalizer. Please ensure that you explicitly call close() on your cursor: select * from A_gtdx where lid =? and tid=?
03-12 14:17:00.954: E/Database(3198): close() was never explicitly called on database '/mnt/sdcard/railway/rail.db'
String sql="select * from A_gtdx where lid =? and tid=? ";
SQLiteDatabase db=databaseHelper.getWritableDatabase();
Cursor cursor=null;
List<Gtdx> glist=new ArrayList<Gtdx>();
Gtdx dx=null;
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
format.setLenient(false);
try{
cursor=db.rawQuery(sql, new String[]{String.valueOf(id) , String.valueOf(tid)});
while(cursor.moveToNext()){
dx=new Gtdx();
dx.setId(cursor.getInt(0));
dx.setTxc(cursor.getDouble(1));
dx.setTxj(cursor.getDouble(2));
dx.setTxzt(cursor.getString(3));
dx.setDx2c(cursor.getDouble(4));
dx.setDx2j(cursor.getDouble(5));
dx.setDx2zt(cursor.getString(6));
dx.setDx3c(cursor.getDouble(7));
dx.setDx3j(cursor.getDouble(8));
dx.setDx3zt(cursor.getString(9));
dx.setDx4c(cursor.getDouble(10));
dx.setDx4j(cursor.getDouble(11));
dx.setDx4zt(cursor.getString(12));
dx.setDx5c(cursor.getDouble(13));
dx.setDx5j(cursor.getDouble(14));
dx.setDx5zt(cursor.getString(15));
dx.setDx6c(cursor.getDouble(16));
dx.setDx6j(cursor.getDouble(17));
dx.setDx6zt(cursor.getString(18));
dx.setDx7c(cursor.getDouble(19));
dx.setDx7j(cursor.getDouble(20));
dx.setDx7zt(cursor.getString(21));
dx.setDx8c(cursor.getDouble(22));
dx.setDx8j(cursor.getDouble(23));
dx.setDx8zt(cursor.getString(24));
dx.setWxr(cursor.getString(25));
dx.setHjr(cursor.getString(26));
dx.setLid(cursor.getInt(27));
dx.setUploadstate(cursor.getInt(28));
dx.setTid(cursor.getInt(29));
dx.setRq(new Timestamp(format.parse(cursor.getString(30)).getTime()));
glist.add(dx);
}
}catch(Exception e){
e.printStackTrace();
}finally{
if(cursor != null){
cursor.close();
}
}
return glist;
------解决方案--------------------
在finally 关闭的时候 try cacth下
if(cursor!=null)try{cursor.close();}catch(Exception e){}
------解决方案--------------------
数据库访问对象用单例模式