如何将光标从一个活动转移到另一个活动

时间:2011-11-20 05:40:59

标签: android

我需要从一个活动到另一个活动的游标值,但它显示为null。

public class TitleActivity extends ListActivity {
/** Called when the activity is first created. */
public Cursor titleCursor = null;
public String blogid;
public String language;
public String titleRowid;
public String rowid;
public int COUNT;
public JSONArray jarray;
protected NotificationManager notify = null;
private int requiredSpace = 0;
private String contentUrl = null;
private String updateTitlesUrl = null;
Cursor ePubDownloadCursor = null;
private Cursor deleteTitleCursor = null;
protected String magid;
protected String pdate;
protected int pos;

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

    try {

     initializeAllCursors();

    } catch (Exception e) {
        VSLog.error(this.getClass(),
                "Error in start up activity" + e.getMessage());
    }

}

private void initializeAllCursors() {
    try {

        // Contains download status , content and id
        ePubDownloadCursor = managedQuery(
                BlogProvider.Constants.CONTENT_URI,
                ConstantValues.EPUBDOWNLOAD, null, null,
                BlogProvider.Constants.PDATE + " DESC ");

        // Contains deleted status , content and id
        deleteTitleCursor = managedQuery(
                BlogProvider.Constants.CONTENT_URI,
                ConstantValues.EPUBDOWNLOAD, null, null,
                BlogProvider.Constants.PDATE + " ASC ");
        notify = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    } catch (Exception e) {
        VSLog.error(this.getClass(),
                "Error cursor inizilization" + e.getMessage());
    }
}

我想在我的另一个活动中删除标题游标我如何得到PLZ帮助...我想知道我如何得到deleteTitlecursor到我的另一个活动,因为我需要将该游标传递给我的另一个类。但我还需要deleteTitle游标titleactivity

1 个答案:

答案 0 :(得分:2)

也许您可以尝试将对象从一个活动传递到另一个活动。您可以使用意图或静态变量
参考:How to pass an object from one activity to another on Android