How to enable adding bookmarks in android webview

Tags: , , ,



I am creating a browser app for android and I want know is there any code that helps to enable adding bookmarks in android webview.

Answer

This is something you will have to add yourself, a WebView literally just displays html content. It doesn’t come with all features like for example Chrome.

To add/save bookmarks you would need to implement a UI for showing the bookmarking button, for entering the URL, for showing a list of previously bookmarked pages etc. Once you have all that you can then get the WebViews current URL by:

webView.getUrl();

and save that to your database.

Then you have the work of displaying a list of saved bookmarks and allowing the users to click them and have the WebView navigate to them.

Here is an example I found (by a simple Google) to help you get started which shows adding a simple bookmarking feature on an WebView: https://www.journaldev.com/15729/android-webview-bookmarks



Source: stackoverflow