I have created an splash screen, which works perfectly. Now I want to load database while showing splash screen and after database has been loaded completely show the application UI.
I have the following code to do this is this right?
public class Splash extends Activity{
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
new LoadDatabase().execute();
}
@Override
protected void onPause() {
super.onPause();
finish();
}
// Load DB
protected class LoadDatabase extends AsyncTask<Context, Integer, String>
{
@Override
protected String doInBackground( Context... params ) {
try {
new DatabaseHelper(getApplicationContext()).initializeDatabase();
} catch (IOException e) {
e.printStackTrace();
}
return "";
}
@Override
protected void onPreExecute() {
super.onPreExecute();
setContentView(R.layout.splash);
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
Intent openMain = new Intent("com.nepways.MAIN");
startActivity(openMain);
}
}
}
Is there any good example or suggestions?? please help me out with this.