Data not displayed first time in android after copying the file from assets to data folder
- by Thinkcomplete
Description
I have used the code tip from http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ to copy a pre-filled data file to the target and handled this in a asynch task
Problem : On starting the application it gives error and shuts down first time, starting again without any change it works perfectly fine.
So first time after the file is copied, the error comes but after that no issues. Please help
Code attached:..
private class CopyDatabase extends AsyncTask<String, Void, Boolean> {
private final ProgressDialog dialog = new ProgressDialog(BabyNames.this);
protected void onPreExecute() {
this.dialog.setMessage("Loading...");
this.dialog.show();
}
@Override
protected Boolean doInBackground(String... params) {
// TODO Auto-generated method stub
try {
namesDBSQLHelper.createDatabase();
return null;
} catch(IOException ioe){
ioe.printStackTrace();
}
return null;
}
protected void onPostExecute(final Boolean success){
if (this.dialog.isShowing()){
this.dialog.dismiss();
}
}
}