Gets the Android bookmarks. - Android android.provider

Android examples for android.provider:Browser

Description

Gets the Android bookmarks.

Demo Code

/*/*  w w  w.  ja  v  a  2  s .  c  o m*/
 * Zirco Browser for Android
 * 
 * Copyright (C) 2010 J. Devauchelle and contributors.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 3 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.Browser.BookmarkColumns;

public class Main{
    private static final Uri BOOKMARKS_URI = Uri
            .parse("content://browser/bookmarks");
    /**
     * Gets the Android bookmarks.
     * @param context The current context.
     * @return A Cursor to Android bookmarks.
     * @throws IllegalStateException Exception.
     */
    public static final Cursor getAllBookmarks(Context context)
            throws IllegalStateException {
        return context.getContentResolver()
                .query(BOOKMARKS_URI,
                        new String[] { BookmarkColumns.TITLE,
                                BookmarkColumns.URL }, "bookmark = 1",
                        null, null);
    }
}

Related Tutorials