Here I am going to explain how to read google chrome history in android studio IDE
private void getBrowserHistory() {
final Uri BOOKMARKS_URI;
BOOKMARKS_URI=Uri.parse("content://android.chrome.browser/bookmarks");
final String[] HISTORY_PROJECTION = new String[]
{
"_id", // 0
"url", // 1
"visits", // 2
"date", // 3
"bookmark", // 4
"title", // 5
"favicon", // 6
"thumbnail", // 7
"touch_icon", // 8
"user_entered", // 9
};
Cursor mCur = this.managedQuery(BOOKMARKS_URI, HISTORY_PROJECTION, null, null,null);
this.startManagingCursor(mCur );
mCur .moveToFirst();
String title = "";
String url = "";
String date="";
if (mCur.moveToFirst() && mCur.getCount() > 0) {
while (mCur.isAfterLast() == false ) {
title= mCur.getString(mCur .getColumnIndex("title"));
url = mCur.getString(mCur .getColumnIndex("url"));
date= mCur.getString(mCur .getColumnIndex("date"));
mCur .moveToNext();
}
}
}
Add the below permission to your Manifest file.
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
Happy Coding:)
No comments:
Post a Comment