How to get Chrome History & Bookmarks in Android Marshmallow (API>=23)? How to get Chrome History & Bookmarks in Android Marshmallow (API>=23)? google-chrome google-chrome

How to get Chrome History & Bookmarks in Android Marshmallow (API>=23)?


Contrary to the cited documentation, com.android.browser.permission.READ_HISTORY_BOOKMARKS is still defined by the framework, and can still be obtained by apps. Unfortunately, on Marshmallow and later, Chrome checks for a different permission, one that regular apps aren't allowed to obtain. For compatibility reasons, when that permission check inevitably fails, Chrome returns zero rows instead of throwing a SecurityException.

You can see the source code here:

query() calls hasReadAccess(), which calls hasPermission("com.android.browser.permission.READ_HISTORY_BOOKMARKS"), which on API >= M ignores the permission argument and instead checks for com.android.chrome.permission.READ_WRITE_BOOKMARK_FOLDERS. This permission is limited to system apps and apps signed with Google's key.