Sqlite로부터 data를 가져와서 하나씩 처리하는 Method를 만들었는데, 작동하지 않는군요.
Method 안에는 tread를 넣고 message를 통해 Handler로 정보가 넘어가 Handler에서 처리합니다.
그리고 Sqlite에서온 Duration동한 Thread를 지연시키고 다음 sqlite정보를 받아 처리합니다.
코드좀 보고 잘못된 부분 지적 부탁합니다.
public void setCommands () {
db = helper.getReadableDatabase();
final Cursor c = db.query("park", null, null, null, null, null, null);
c.moveToLast();
msg.what = 0;
mthread = new Thread(new Runnable() {
@Override
public void run() {
int duration = 0;
int parameter = 0 ;
int commandIndex = 0 ;
while (c.moveToPrevious()) {
String car_kind = c.getString(c.getColumnIndex("command"));
commandIndex = selectionMatch(car_kind);
String car_owner = c.getString(c.getColumnIndex("parameter"));
if (car_owner.equals("")) {
parameter = 0;
}
else {
parameter = Integer.parseInt(car_owner);
}
String num = c.getString(c.getColumnIndex("duration"));
if (num.equals("")) {
duration = 0;
}
else {
duration = Integer.parseInt(num);
}
msg.what = commandIndex;
msg.arg1 = parameter;
mainHandler.sendMessage(msg);
try{
Tread.sleep(duration * 500);
}
catch (InterruptedException e) {;}
}
}
});
mthread.start();
}