javaandroidkotlinbrowser-history

Is there really a way to save history of visited sites so that when user comes back(reopens app) he has the list of visited sites on back press


I am just making a simple browser with history management.


Solution

  • Perhaps you could look to an open source project like the Zirco Browser -> https://code.google.com/p/zirco-browser/

    Some code like this > https://code.google.com/p/zirco-browser/source/browse/branches/tint-browser-old2/src/org/tint/controllers/BookmarksHistoryController.java

       /**
             * Get a Cursor the history, e.g. records wich have a visits count > 0. Sorted by last visited date.
             * @param currentActivity The parent activity.
             * @return A Cursor to history records.
             * @see Cursor
             */
            public Cursor getHistory(Activity currentActivity) {
                    String whereClause = Browser.BookmarkColumns.VISITS + " > 0";
                    String orderClause = Browser.BookmarkColumns.DATE + " DESC";
    
                    return currentActivity.managedQuery(android.provider.Browser.BOOKMARKS_URI, Browser.HISTORY_PROJECTION, whereClause, null, orderClause);
            }
    

    Perhaps you could copy some code and use it for your project.