开发者

Trying to list Android Bookmarks showing History as well

开发者 https://www.devze.com 2023-01-15 08:54 出处:网络
I\'m trying to list the system default bookmarks but when I run the app, it list not only the bookmarks but also show History URLs and Most Visited URLs.

I'm trying to list the system default bookmarks but when I run the app, it list not only the bookmarks but also show History URLs and Most Visited URLs.

How can I avoid this and show only the bookmarks?

here is the method: (imported everything necessary + permissions valid)

public class CLASSNAME extends ListActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        String[] projection = new String[] {Browser.BookmarkColumns._ID, 
                                     Browser.BookmarkColumns.TITLE, 
                                     Browser.BookmarkColumns.URL};
        String[] displayFields = new String[] {Browser.BookmarkColumns.TITLE, 
                                     Browser.BookmarkColumns.URL};
        int[] displayViews = new int[] { android.R.id.text1, 
              开发者_Python百科                       android.R.id.text2 };

        Cursor cur = managedQuery(android.provider.Browser.BOOKMARKS_URI, 
                       projection, null, null, null);
        setListAdapter(new SimpleCursorAdapter(this, 
                       android.R.layout.simple_list_item_2, cur, 
                       displayFields, displayViews));
   }
}


Solution:

Replace the first "null" to "android.provider.Browser.BookmarkColumns.BOOKMARK" Cursor cur = managedQuery(android.provider.Browser.BOOKMARKS_URI, projection, null->android.provider.Browser.BookmarkColumns.BOOKMARK, null, null);

Hope this helps anyone else :)

0

精彩评论

暂无评论...
验证码 换一张
取 消