mercredi 4 février 2015

show dialog when upgrading database

first, i apologize my english is kiddy.


i want to show dialog when upgrading databse. now i tried creating AsyncTask and put upgrade logic on 'doInBackground'. and, used to 'preExecute' and 'postExecute' to showDialog.


it seems to good work. but, it has critical problem.


when user do force close Application (use task killer or task manager), android system is misunderstand every work is well done.


look at this flow


[good work]


databaseVersion = 1;




  1. do onUpgrade()




  2. execute AsyncTask.




  3. onPreExecute(), showProgressDialog.




  4. doInBackground(), migrating Database.




  5. onPostExecute(), dismissProgressDialog.




databaseVersion = 2;




[bad work]


databaseVersion = 1;




  1. do onUpgrade()




  2. execute AsyncTask.




  3. onPreExecute(), showProgressDialog.




  4. doInBackground(), migrating Database.




  5. force stop application (use task killer or task manager)




databaseVersion = 2;


database migration is not executed completely, but databaseVersion is 2!!


how can i solve this problem?


Aucun commentaire:

Enregistrer un commentaire