Passing cursor to activity?

Is it possible? I am trying to open the SQLite database cursor in one action and pass it to another action.

+2
source share
3 answers

I personally do not know any simple ways to do this. It might be easier to just make the request again in the assignment operation.

+3
source

, , . . , " " , . , - Application ( (, , . -, .):

    package com.jcascio.k03;

    import android.app.Application;
    import android.database.Cursor;

// use your application name instead of "K03Application"

        public class K03Application extends Application { 

        public final String TAG = "K03";

        Cursor sharedCursor; // this cursor can be shared between different Activities

        @Override
        public void onCreate() {
            super.onCreate();
        }

        @Override
        public void onTerminate() {
            super.onTerminate();
        }


        public Cursor getSharedCursor() 
        {
            return this.sharedCursor;
        }

        public void setSharedCursor(Cursor c)
        {
            this.sharedCursor = c;
        }

    }

    this.getApplication()

// You cast it to your Application sub-class and call the Cursor accessor function

Cursor c = ((K03Application)this.getApplication()).getSharedCursor();

, goo, Cursor. setSharedCursor . , getSharedCursor onCreate ( ), .

+5

, Parcelable. putExtra(). ( ) Parcel ( Binder).

+1

Source: https://habr.com/ru/post/1776065/


All Articles