开发者

Data not displayed first time in android after copying the file from assets to data folder

I have used the code tip from here to copy a pre-filled data file to the target and handled this in a asynch task.

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.

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 Bo开发者_如何学Colean 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();
        }
    }
}


Try copying database by this way.It looks same as the answer of the link provided by you but it has some difference. Database not copying from assets

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜