sqlite - Display Please wait while upgrading database in android -


i want upgrade db in next update, i've faced problem. upgrading heavy , spends 2-3 minute in device ( depends on hardware of device ) , contains delete table create table , move data old table new table, don't want user see white screen while upgrading, , database upgrading first command runs can't start activity see please waiting or other data.

for solving issue i've used asynctask class, in onupgrade of database execute asynctask class upgrading, , can start splash screen notify user application need time. solution lost transactional behaviour , if device has been turned off, or application killed application faced bigger problem.

i know how run multiple codes in transactional, understand, database version has been increased , next time launch application database don't upgrade anymore , application doesn't work anymore. ( because new table not exists).

i think on 1 solution keep track upgrade database , save sharedpref , in next launch check value in sharedpreference , if upgrade has been complete let user use application, else finish upgrade process.

i don't think best way, want ask you, other solution exists upgrade database in background , if problem happened database upgrade start on again?

thanks in advance, , time.

ps: know if error happened in onupgrade, database upgrading start on when move upgrading ui thread thread not happened anymore, , don't know why.

first don't have enough reputation comment why writing answer.

why don't on server side? use server side scripting language , whenever upgrading database put lock on database , if user tries access database display message "currently , under maintenance : come after few minutes".

in way won't interfere in users work , user won't mine coming in few minutes.

i think better using sharedpreference in both speed , reliability.

hope helps. if need in ask in comment.


Comments