Posts

Showing posts from April, 2011

Read bookmark details from Browser provider

Image
Here simply I am reading the contents from the browser provider, bookmark table and listing it in a textView. The contents I am reading here are the title and the URL

The code snippet is,



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) {
tv.append("\n" + mCur.getString(titleIdx));
tv.append("\n" + mCur.getString(urlIdx));
mCur.moveToNext();
}



You also need to put the permission,


<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />


Screen shot




Get the complete source code from here

Custom Adapter crashes

Wehen I created a custom adapter for a listView, with each list item inflating from a layout. using the statement,


convertView = vi.inflate(R.layout.list_item, parent);

my application crashed, later I put a false to the statement and worked well. The new statement looks like

convertView = vi.inflate(R.layout.list_item, parent, false);