Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use managedQuery in the service Android?

I have this method but it works only in an activity

public Cursor getXX() {
        Cursor mCur = thius.managedQuery(Browser.BOOKMARKS_URI,Browser.HISTORY_PROJECTION, 
                             null, null, null);
}

public void getBrowserHist()  {
    Cursor mCur = managedQuery(Browser.BOOKMARKS_URI, Browser.HISTORY_PROJECTION, 
                             null, null, null);
    mCur.moveToFirst();
    if (mCur.moveToFirst() && mCur.getCount() > 0) {
        while (mCur.isAfterLast() == false) {
            Log.v("titleIdx", mCur.getString(Browser.HISTORY_PROJECTION_TITLE_INDEX));
            Log.v("urlIdx", mCur.getString(Browser.HISTORY_PROJECTION_URL_INDEX));
            mCur.moveToNext();
        }
    }
}

How can I use the words "ManagedQuery" in android Service?

How can I create a method to return the cursor to the browser history android system?

like image 897
user2282259 Avatar asked Jan 14 '23 13:01

user2282259


1 Answers

managedQuery() has been deprecated for over two years and is only relevant for Activity.

Your Service can call getContentResolver(), and call query() on it, to query your desired ContentProvider.

like image 192
CommonsWare Avatar answered Jan 21 '23 05:01

CommonsWare