Trying to get Search results from android browser
I am trying to get my search values from the android browser with following code:
public void getBrowserHist() {
String[] mColumnStrings =
{ Browser.SearchColumns._ID,
Browser.S开发者_Python百科earchColumns.SEARCH,
Browser.SearchColumns.DATE
};
Cursor mCur = getContentResolver().query(Browser.SEARCHES_URI,
mColumnStrings, Browser.SearchColumns.SEARCH, null, null);
int url = mCur.getColumnIndex(Browser.SearchColumns.SEARCH);
Log.d(DEBUG_TAG, "Bookmarks count: " + mCur.getCount());
mCur.moveToFirst();
while (!mCur.isAfterLast()) {
Log.v("titleIdx", mCur.getString(url));
mCur.moveToNext();
}
}
The problem is that search result is empty. the mcur.getCount() method returns 0, and I don´t now why. Does anyone have any suggestion?
Cursor cursor = this.context.getContentResolver().query(Browser.SEARCHES_URI, null, null, null, null);
if (cursor.moveToFirst()) {
while (!cursor.isAfterLast()) {
final int indexDate = cursor.getColumnIndex(Browser.SearchColumns.DATE);
final int indexTerm = cursor.getColumnIndex(Browser.SearchColumns.SEARCH);
String date = cursor.getString(indexDate);
String term = cursor.getString(indexTerm);
cursor.moveToNext();
}
}
cursor.close();
精彩评论