Android 无法恢复活动:尝试重新查询已关闭的光标

Android 无法恢复活动:尝试重新查询已关闭的光标,android,android-sqlite,android-cursor,android-contentresolver,android-cursorloader,Android,Android Sqlite,Android Cursor,Android Contentresolver,Android Cursorloader,我正在做一个项目,我正在做的是检查阅读RSS提要并将它们保存到我的数据库中,然后通过在列表视图中选择特定的故事来显示它们。当我显示我正在使用Webview的故事时,如果它出现在Webview中的故事内容中,我还可以打开url。一切正常 现在我只想检查如果在webview中的故事内容中单击的url是否存在于my数据库中,那么该数据库应该在my activity中使用一些HTML标记和webview打开。如果我的数据库中不存在该url,则该url应作为链接在我的webview中打开。不过一切都很顺利

我正在做一个项目,我正在做的是检查阅读RSS提要并将它们保存到我的数据库中,然后通过在列表视图中选择特定的故事来显示它们。当我显示我正在使用Webview的故事时,如果它出现在Webview中的故事内容中,我还可以打开url。一切正常

现在我只想检查如果在webview中的故事内容中单击的url是否存在于my数据库中,那么该数据库应该在my activity中使用一些HTML标记和webview打开。如果我的数据库中不存在该url,则该url应作为链接在我的webview中打开。不过一切都很顺利

问题是,如果url匹配,它会按照我的要求打开,但当我按下backbutton时。它崩溃,然后在强制关闭时返回到“返回”活动。然而,如果我单击数据库中不存在的url,它就可以正常工作

任何帮助都是有用的,我在这里附上我的代码也是为了同样的目的

content = (WebView) findViewById(R.id.content);

            if(getStoryFromDB()!=null){
                Uri uri = Story.buildStoryUri(getStoryFromDB());
                Intent intent = new Intent("com.india.ui.StoryDetailIntent2.LAUNCH",uri );
                Log.d("uri passed:", uri.toString());
                startActivity(intent);
                //Toast.makeText(this, "Story URL Matched", Toast.LENGTH_LONG).show();
            }
            else{

            content.getSettings().setPluginState(PluginState.ON_DEMAND);
            content.getSettings().setJavaScriptEnabled(true);
            content.getSettings().setAllowFileAccess(true);
            content.setWebChromeClient(new WebChromeClient());
            content.setWebViewClient(new WebViewClient());

            content.loadUrl(surl);
            }

private String getStoryFromDB() {
        // TODO Auto-generated method stub
         StoryDatabase storiesdb = new StoryDatabase(this);
         SQLiteDatabase sqldb = storiesdb.getReadableDatabase();
         String sStoryGuid=null;
         String selection =  StoryColumns.LINK+"=?" ;
         String[] selectionArgs = new String[1];
         selectionArgs[0] = surl;
         try{
         Cursor cursor = sqldb.query(StoryDatabase.Tables.STORIES, null, selection, selectionArgs, null, null, null);
         startManagingCursor(cursor);
            while (cursor.moveToNext()) {
                sStoryGuid = cursor.getString(cursor.getColumnIndex(StoryColumns.GUID));
                StoriesBean objSb = new StoriesBean();
                objSb.setGuid(sStoryGuid);
                }
         }catch(Exception e){
             e.printStackTrace();
         }finally{
                sqldb.close();   
         }
         return sStoryGuid;
    }
我搜索了它,认为我找到了原因,因为我正在使用startManagingCursor()。现在它已经被弃用了,我应该使用contentResolver或loader。但是我不能把它写进代码中,我也不知道如何实现它。我搜索了一下,但找不到任何解决方法

任何帮助都将不胜感激。提前谢谢。

我猜:

sqldb.close()-

但是startManagingCursor需要它来重新查询。此光标将在活动的
onDestroy()中关闭

关于装载机,建议我理解它