开发者

Trying to list Android Bookmarks showing History as well

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜