Get browser history and search result in android

前端 未结 2 501
野趣味
野趣味 2020-12-09 07:33

I am trying to get the history and search results from the android browser. In the following code I get all the bookmarks, which works great:

public void get         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-09 08:12

    Try this:

    package higherpass.TestingData;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.provider.Browser;
    import android.widget.TextView;
    import android.database.Cursor;
    
    public class TestingData extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            TextView view = (TextView) findViewById(R.id.hello);
            String[] projection = new String[] {
                Browser.BookmarkColumns.TITLE
                , Browser.BookmarkColumns.URL
            };
            Cursor mCur = managedQuery(android.provider.Browser.BOOKMARKS_URI,
                projection, null, null, null
                );
            mCur.moveToFirst();
            int titleIdx = mCur.getColumnIndex(Browser.BookmarkColumns.TITLE);
            int urlIdx = mCur.getColumnIndex(Browser.BookmarkColumns.URL);
            while (mCur.isAfterLast() == false) {
                view.append("n" + mCur.getString(titleIdx));
                view.append("n" + mCur.getString(urlIdx));
                mCur.moveToNext();
            }
    
        }
    }
    

    extracted from here

提交回复
热议问题