Android History Bookmark

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. :)

Download Source Code

 

About the author

I am an Android developer for whom Android is the one and only love. I work as a freelancer which gets me and Android closer. I always love to share my learnings and love to learn from others knowledge too.

COMMENTS (14)
Reply

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);

Reply

how to get bookmarks history to firebase??

    Hi Samir,

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

    Thanks

Reply

how to save data bookmark to firebase??

    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

    Hi Steve,

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

    Thanks

Reply

hallo sir,

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

    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

Reply

halo sir.
this app can running in background??

    Hi Samid,

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

    Thanks

Reply

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?

    Hi Samid,

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

    Thanks

Leave a Comment

Comment (required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Name (required)
Email (required)