Android read browser history Android read browser history android android

Android read browser history


Not really an answer but I can tell you what I did.

I first clone the browser repo and try to reproduce how they get the history.And I started getting:

Permission Denial: readingcom.android.browser.BrowserProvider

So I added:

<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />

But it still is giving me the same error. I google it and I found this Accessing Data With Android Cursors.

Hope it helps.


managedQuery has been deprecated so use getContentResolver instead, use the following code:

String[] proj = new String[] { Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL };String sel = Browser.BookmarkColumns.BOOKMARK + " = 0"; // 0 = history, 1 = bookmarkCursor mCur = getContentResolver().query(Browser.BOOKMARKS_URI, proj, sel, null, null);mCur.moveToFirst();@SuppressWarnings("unused")String title = "";@SuppressWarnings("unused")String url = "";if (mCur.moveToFirst() && mCur.getCount() > 0) {    boolean cont = true;    while (mCur.isAfterLast() == false && cont) {        title = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.TITLE));        url = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.URL));        // Do something with title and url        mCur.moveToNext();    }}

Also add permissions using

<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />


For Lollipop or earlier

I am able to get the history by using the following code:

Cursor mCur = activity.managedQuery(Browser.BOOKMARKS_URI,                    Browser.HISTORY_PROJECTION, null, null, null);            if (mCur.moveToFirst()) {                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();                }            }