I am working on SQLite db. I have a thread which on execution puts data into the specific table. Inside the activity I want to wait till there is any data inside the same table.
To achieve this I tried read data using while loop but it is not giving desired values.
Is there any way to do this? In case is there any way to get insert trigger in in android?
code to continuous check:
boolean flg = false;
Log.d("Start", "Start while");
while(!flg){
try {
if((!(db.getResponse().equals(""))) || (db.getResponse().length()) > 0){
flg = true;
responseXML = db.getResponse();
}
wait(1000);//1000 = 1 sec
Log.d("Start", "wait while");
} catch (Exception e) {
// TODO: handle exception
}
}
Log.d("Start", "end while");
db.getResponse()
function code :
public String getResponse(){
String readResponse = "";
// Select All Query
String selectQuery = "SELECT * FROM " + TABLE_TEMPRESPONSE;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to list
if(cursor != null && cursor.getCount()>0){
if (cursor.moveToFirst())
readResponse = ""+cursor.getString(1);//response
}
cursor.close();
db.close();
return readResponse;
}
Aucun commentaire:
Enregistrer un commentaire