Android History Bookmark - Androhub

Browser History

Android History Bookmark

In Android you can access your Browser history and Bookmarks. For more details about Android Browser check developers site.

In this tutorial we are going to fetch all bookmarks and browser history and show them over ListView.

For fetching Browser data we are going to use Browser.BookmarkColumns. This contains all the columns against Bookmark and History of browser.

VIDEO DEMO

Let’s start with example.

1. Create a new project in Eclipse by navigating to File ⇒ New Android ⇒ Application Project and fill required details. By default my activity is MainActivity.java.

2. To work on Android History and Bookmarks we need a uses permission in Manifest file. This permission in mandatory.

3. Now, create a xml layout contains ListView for displaying bookmarks. I named this layout as activity_main.xml.

4. I am using a custom listview here , so i need a new xml layout i.e. custom_view.xml for custom view. If you are new to Custom ListView you can check its tutorial here.

5. Create  a getter and setter java class naming BookmarkModel.java for Bookmark Listview.

6. Now, create a custom adapter naming Custom_Adapter.java. In this class we inflate a custom layout and set the bookmark title and Url over textview.

7. We are going to use Cursor and Content Resolver to fetch Bookmarks details. And add the details into arrayList.

8. Finally come to MainActivity.java and add the following code. In this class we fetch the bookmark history and add the Bookmark Title and Bookmark URL to arrayList and set over listview.

9. Now, you are all done, run your app and you will get the output as shown in video.

Thanks. :)

 

17 Comments

Raja Usman
Sunday, September 30th, 2018

i can’t resolve this problem of (BOOKMARKS_URI and BookmarkColumns.URL) can you help me

Cursor cursor = getContentResolver().query(
Browser.BOOKMARKS_URI,
new String[] { Browser.BookmarkColumns.TITLE,
Browser.BookmarkColumns.URL }, null, null, null);

Dr. Droid
Monday, October 8th, 2018

Hi Raja,

Actually the code was written long back on Eclipse so may be that’s why its creating issue.

You can check this link : https://stackoverflow.com/questions/32535325/browser-bookmarks-uri-not-working-in-android-studio

May be it will help you.

Thanks

samid
Tuesday, January 22nd, 2019

how to get bookmarks history to firebase??

Dr. Droid
Wednesday, January 23rd, 2019

Hi Samir,

What exactly you want with firebase? Can you elaborate it?

Thanks

samid
Monday, February 18th, 2019

how to save data bookmark to firebase??

Dr. Droid
Monday, February 18th, 2019

Hi Samid,

From this article you got to know how to fetch bookmark and about how to save data in firebase see this link.

Thanks

stevemaster92
Thursday, February 21st, 2019

Is this still possible? According to API doc https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-bookmark-browser this shouldn’t.

Is there another solution for Android 6 and later?

Dr. Droid
Thursday, February 21st, 2019

Hi Steve,

Yes i think this history bookmark wont work for API level 6+.

Thanks

samid
Monday, February 25th, 2019

hallo sir,

I completed this task, can this task be connected to Firebase?

Dr. Droid
Tuesday, February 26th, 2019

Hi Samid,

In last comment reply i shared you the link of Firebase Realtime Database link. Have you gone through it?

If not then first go through it to check how to implement it and in case you face any issue let me know.

Thanks

samid
Friday, March 15th, 2019

halo sir.
this app can running in background??

Dr. Droid
Sunday, March 17th, 2019

Hi Samid,

I didn’t get you what you are trying to say?

Thanks

samid
Sunday, March 17th, 2019

halo sir,
I completed this task,

how to run this application in the background and add bookmarks in real time without having to open the application again?

Dr. Droid
Tuesday, March 19th, 2019

Hi Samid,

You have to make a service which will be running in background.

Thanks

samid
Monday, April 29th, 2019

How to make service which will be running in background??

Dr. Droid
Tuesday, April 30th, 2019

Hi Samid,

Check this link. You will get an idea how to run a service in background.

Thanks

Ajay
Monday, April 20th, 2020

sir how i add only history button in webview brower
please sir help me

Post comment

Your email address will not be published. Required fields are marked *