Following code demonstrates retrieving visited website title, no. of times that website visited and whether it is bookmarked or not.
Write the following code in onCreate() method.
String[] requestedColumns = { Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.VISITS, Browser.BookmarkColumns.BOOKMARK }; Cursor faves = managedQuery(Browser.BOOKMARKS_URI, requestedColumns, null, null, null); Log.d(DEBUG_TAG, "Bookmarks count: " + faves.getCount()); int titleIdx = faves.getColumnIndex(Browser.BookmarkColumns.TITLE); int visitsIdx = faves.getColumnIndex(Browser.BookmarkColumns.VISITS); int bmIdx = faves.getColumnIndex(Browser.BookmarkColumns.BOOKMARK); faves.moveToFirst(); int count = 0; while (!faves.isAfterLast()) { Log.d(DEBUG_TAG, "Inside while --- : " + count); Log.d("SimpleBookmarks",faves.getString(titleIdx) + " visited " + faves.getInt(visitsIdx) + " times : " + (faves.getInt(bmIdx) != 0 ? "true" : "false")); faves.moveToNext(); count++; }
Hi,
To access web history you need to use Browser class available in android.provider package.
Try following code it may be helpful to you.
Cursor mCur = activity.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();
}
}