Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android read browser history

I want to read browser history in Android phone.

I have done some document reading, then I come to know that we can read browser history by android.provider.Browser class. It has :

final static Cursor getAllVisitedUrls(ContentResolver cr) 

...method which returns Cursor.

May I get help to handle Cursor, or any example code to get browser history?

like image 377
Mitul Nakum Avatar asked Apr 05 '10 05:04

Mitul Nakum


People also ask

Can someone see my browsing history from another phone?

An app legally installed on someone else's phone won't be associated with any privacy-violating actions. Of course, you need to get the consent of the target person before you start monitoring their activity. However, if you're going to check on your underage child, you can freely use eyeZy without them knowing.

How can I check deleted history on my phone?

Enter your Google account credentials and tap on the "Data & Personalization" option; Press the view all button under the "Things you create and do" section and look for Google Chrome's icon; Tap on it and then hit the "Download Data" option to recover the deleted bookmarks and browsing history.

Can you search history on Android?

Control your Search historyOn your Android phone or tablet, open the Google app . Controls. On the "Web & App Activity" card, tap Auto-delete (Off). If you find “Auto-delete (On),” Google automatically deletes your Web & App Activity, which includes your Search history, after a specific time period.


2 Answers

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: reading com.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.

like image 131
Macarse Avatar answered Sep 30 '22 18:09

Macarse


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 = bookmark Cursor 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" /> 
like image 27
Aditya Avatar answered Sep 30 '22 18:09

Aditya