0

我正在使用 rawQuery 方法将数据列表作为 Cursor 并使用 startManagingCursor() 和 stopManagingCursor() 方法。Activity1 和 Activity2 没有问题,但是当我尝试从 Activity3 转到 Activity2 时,它说04-09 17:37:59.629: E/AndroidRuntime(6509): java.lang.RuntimeException: Unable to resume activity {com.nepways.nlocate/com.nepways.nlocate.BusinessOrganizationActivity}: java.lang.IllegalStateException: database /data/data/com.nepways.nlocate/databases/nLocateDatabaseNew.db already closed 有人有帮助吗?
更新代码

    public class BusinessActivity extends Activity implements OnItemClickListener {

    private ArrayList<Business> businessList = new ArrayList<Business>();
    private BusinessListAdapter businessListAdapter;
    private ListView lvBusiness;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.business_list);

        businessList = getIntent().getParcelableArrayListExtra("businessList");

        businessListAdapter = new BusinessListAdapter(this, businessList);

        lvBusiness = (ListView) findViewById(R.id.lvBusiness);
        lvBusiness.setAdapter(businessListAdapter);
//      lvBusiness.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
        // TODO Auto-generated method stub

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        menu.add("Search").setIcon(R.drawable.ab_search).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
//      return super.onCreateOptionsMenu(menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if(item.getTitle().toString().equalsIgnoreCase("Search")) {
            startActivity(new Intent(this, SearchActivity.class));
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

}
4

1 回答 1

1

请打开您的数据库,清楚地提到您的数据库已关闭。

打开数据库调用 getReadableDatabase()

于 2012-04-09T11:56:41.177 回答