커스텀 리스트뷰를 만들었습니다. 어플 리스트인데요.
그런데 문제가 체크박스가 계속 유지되도록 DB에 저장 해둔 뒤
다시 리스트뷰가 있는 액티비티로 가졌을 때 DB과 같은 어플이름이 있는 위치에는 다시 체크가 되게 해놧습니다.
여기서 문제가 다시 체크가 될 시에 DB에 다시 또 저장 된다는 점입니다.
그래서 제가 어댑터에 조건을 주었는데요... 잘 안되는 것같아 이렇게 질문을 올립니다ㅜ
try {
// DB객체 생성(DB가 존재하지 않으면 생성함)
DBManager dbmgr = new DBManager(SlideApplicationChooserActivity.this);
SQLiteDatabase sdb;
// DB연결
sdb = dbmgr.getWritableDatabase();
Cursor cursor = sdb.rawQuery("select app from customers where '"+appList.appName+"'", null);
if(cursor.isFirst()){//중복저장방지
while(cursor.moveToNext()){
String app = cursor.getString(0);
if(appList.isCheck){ // 체크되 있다면
if(app==appList.appName) break; //서로 같으면
else sdb.execSQL("insert into customers values('" + appList.appName+ "');");//서로 다르면
}
else //안되 있다면
sdb.execSQL("delete from customers where app = '" + appList.appName + "';");
}
}
else{//초기 체크
if(appList.isCheck){
sdb.execSQL("insert into customers values('" + appList.appName+ "');");
}
else
sdb.execSQL("delete from customers where app = '" + appList.appName + "';");
}
// DB닫음
dbmgr.close();
} catch (SQLiteException e) {
// 예외처리(생략)
}