看来,打开帮助器框架的打算用途是打开活动启动数据库,并在活动销毁时关闭它。
在从的AsyncTask内的onCreate()...
new StartupTask().execute();
的的AsyncTask Thread.sleep()方法下面只是给足够的时间来显示对话框,让你可以看到它的工作。很明显,当你完成比赛时就把它拿出来。 )
private class StartupTask extends AsyncTask
{
private ProgressDialog progressDialog;
@Override
protected Object doInBackground(final Object... objects)
{
openHelperRef.getWritableDatabase();
try
{
Thread.sleep(5000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
return null;
}
@Override
protected void onPreExecute()
{
super.onPreExecute();
runOnUiThread(new Runnable()
{
public void run()
{
progressDialog = ProgressDialog.show(
MyActivity.this, "Title",
"Opening/Upgrading the database, please wait", true);
}
});
}
@Override
protected void onPostExecute(Object object)
{
super.onPostExecute(object);
progressDialog.dismiss();
}
}
中的onDestroy()
... openHelper.close();