오픈 도우미 프레임 워크의 의도 된 사용은 활동 시작시 db를 열고 활동이 삭제 될 때 닫는 것 같습니다. 에서 onCreate() 내에서 AsyncTask를에서
은 ...
new StartupTask().execute();
AsyncTask를 Thread.sleep를() 아래 당신이 그 일을 볼 수 있도록 대화 상자를 표시 할 수있는 충분한 시간을 제공하는 것입니다. 연주를 마쳤을 때 분명히 그것을 꺼내십시오.)들의 OnDestroy()에서
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();
}
}
... openHelper.close();