日期:2014-05-16  浏览次数:20558 次

数据库转移到sd卡AsyncTask,ProgressDialog使用

private class ExportDatabaseFileTask extends AsyncTask<String, Void, Boolean> {?
? ? ? ?
private final ProgressDialog dialog = new ProgressDialog(ctx);?
?
? ? ? ?
// can use UI thread here?
? ? ? ?
protected void onPreExecute() {?
? ? ? ? ? ?
this.dialog.setMessage("Exporting database...");?
? ? ? ? ? ?
this.dialog.show();?
? ? ? ?
}?
?
? ? ? ?
// automatically done on worker thread (separate from UI thread)?
? ? ? ?
protected Boolean doInBackground(final String... args) {?
?
? ? ? ? ? ?
File dbFile =?
? ? ? ? ? ? ? ? ? ?
new File(Environment.getDataDirectory()