Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can we get chrome browsing history/bookmarks in our android app

can we get chrome browsing history/bookmarks like we get in default browser using READ_HISTORY_BOOKMARKS permission? PS:I Just want to know is it possible?

like image 515
Krishna Bhatia Avatar asked Oct 30 '12 10:10

Krishna Bhatia


People also ask

Can I see my Google Chrome bookmarks Mobile?

FAQs. Can I sync my Chrome bookmarks on any device? As long as your device can run the Chrome browser, you can sync your bookmarks to it. This includes Android, iOS, Windows, and macOS.

Can you export bookmarks from Chrome on Android?

Similarly to the iPhone step above, it's not possible to export your Chrome bookmarks directly from within your Chrome app on Android. The easiest way to access your Android Chrome bookmarks on another device is to sync them with your Google account.


1 Answers

Yes it is very much possible. Use this uri: content://com.android.chrome.browser/bookmarks instead of Browser.BOOKMARKS_URI

String[] proj = new String[] { Browser.BookmarkColumns.TITLE,Browser.BookmarkColumns.URL };
Uri uriCustom = Uri.parse("content://com.android.chrome.browser/bookmarks");
String sel = Browser.BookmarkColumns.BOOKMARK + " = 0"; // 0 = history, 1 = bookmark
Cursor mCur = getContentResolver().query(uriCustom, 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();
    }
}

Havent tested the code for errors but it should work fine. The important thing is knowing the uri to use. Reading this and this might help.

like image 101
Aditya Avatar answered Nov 04 '22 13:11

Aditya