-1
我有一個查詢,我想每30秒執行一次並將其記錄到Logcat。我是通過處理程序完成的,我沒有得到迴應。如何在android中每30秒執行一次查詢?
這裏是我的代碼:
runnable = new Runnable() {
@Override
public void run() {
Cursor cursor = null;
int i;
try {
String sql = "SELECT * FROM info";
cursor = database.rawQuery(sql, null);
} catch (SQLException sqle) {
throw sqle;
}
if (cursor != null && cursor.getCount() != 0) {
cursor.moveToFirst();
do {
i = cursor.getCount();
} while (cursor.moveToNext());
cursor.close();
if (i > count) {
count = i;
Log.i("COUNT", "" + count);
}
}
handler.postDelayed(runnable, 30000);
}
};
runnable.run();
如果有人能幫助我,我將不勝感激。