안녕하세요~!
안드로이드 개발 입문자 입니다.
다름이 아니라 이번에 프로젝트를 진행 하게 되었는데
궁금한 점이 있어서 올립니다.
CostomDbHelper customDbHelper = null;
SQLiteDatabase mDatabase = null;
ContentValues cv = new ContentValues();
cv.put("IS_CONFIRM", isChecked ? "Y" : "N");
cv.put("UPDATE_DATE", new SimpleDateFormat( context.getString(R.string.date_format) + " " +context.getString(R.string.time_format) ).format(new Date()));
try{
customDbHelper = new CostomDbHelper(context, false);
mDatabase = customDbHelper.getWritableDatabase();
mDatabase.update(WindfallTODODBHelper.TALBE_NAME , cv, "SEQ=" + aTodo.getSeq(), null);
}catch(Exception e){
Toast.makeText(context, "confirm Exception:" + e.toString(), Toast.LENGTH_LONG).show();
Log.e("excuteTODO Exception:", e.toString());
}finally{
try{
if( mDatabase != null ){ mDatabase.close(); }
if( customDbHelper != null ){ customDbHelper.close(); }
}catch(Exception e){}
}
보통 DB를 쓰게 되면 try catch finally로 감싸주고
close를 하고는 하는데...책이나 SQLiteOpenHelper 사용 방법을 찾아보니
close를 하거나 Exception 처리를 잘 안하는거 같아서...
굳이 할 필요가 없는 건지... 아님 선택 사항인지 알고 싶습니다.
뭐 try catch야 선택 사항이라고 생각 하면 될것 같지만...
db.close() 나 sqlite.close()를 굳이 안해도 되는건지 알고 싶습니다.