这里是db适配器查询
public void postCheck(String addr) {
openConn();
Cursor cur = db.rawQuery("select " + ALAMAT + " from " + TableName, null);
if(addr == ALAMAT && cur != null) {
cur.moveToFirst();
Toast.makeText(konteks, "Anda ada tugas",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(konteks, "Anda tidak ada tugas",
Toast.LENGTH_LONG).show();
}
closeConn();
}
这是活动中的代码
public void cekTugas() {
//cek tugas
if(alamat != "") {
dbHandler.postCheck(alamat);
}
}
我把它放在onCreate
中的线程之后//thread untuk menjalankan LBS
timer = new Timer();
timer.schedule(new TimerTask() {
Handler handlerLokasi = new Handler(Looper.getMainLooper());
@Override
public void run() {
// TODO Auto-generated method stub
handlerLokasi.post(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
cekLokasi();
}
});
}
}, 0, 300000);
//cek tugas
cekTugas();
感谢您的帮助......