Zen
Zen

Reputation: 2728

Android wait to write SQLite query

Im uploading an image to my server and so what I want to do is, while its uploading, 1) Write data to SQLiteDatabase 2) Once upload is complete write some more data to additional columns

But if the upload is complete, but its still in stage 1; I want it to wait till (1) is completed before writing the additional data.

//Write data to SQLIte table 
writeBeforeSave();

public void onUploadCompleteCallback()
{
   //If writeBeforeSave is complete execute; else wait till its finished
   writeAfterSave();
}

Upvotes: 0

Views: 320

Answers (1)

Dan Cantir
Dan Cantir

Reputation: 2955

I think AsyncTask is exactly what you need.

Follow this link to browse some examples. Also here you've got a good illustration of how it works:

enter image description here

Good luck!

Upvotes: 1

Related Questions