Android Tutorial

(avery) #1

By : Ketan Bhimani


334 

while (!faves.isAfterLast()) {
Log.d(“SimpleBookmarks”, faves.getString(titleIdx)+ “visited“ +
faves.getInt(visitsIdx)+“times:“+(faves.getInt(bmIdx)!=0?“true”:
“false”));
faves.moveToNext();
}


Again,the requested columns are defined, the query is made, and
the cursor iterates through the results.

Note that the managedQuery() call has become substantially more
complex. Let’s take a look at the parameters to this method in
more detail. The first parameter, Browser .BOOKMARKS_URI, is a
URI for all browser history, not only the Bookmarked items. The
second parameter defines the requested columns for the query
results. The third parameter specifies that the bookmark property
must be true. This parameter is needed in order to filter within the
query. Now the results are only browser history entries that have
been bookmarked. The fourth parameter, selection arguments, is
used only when replacement values are used, which is not used in
this case, so the value is set to null. Lastly, the fifth parameter
specifies an order to the results (most visited in descending order).
Retrieving browser history information requires setting the READ_
HISTORY_ BOOKMARKS permission.

Using the Contacts Content Provider

The Contacts database is one of the most commonly used
applications on the mobile phone. People always want phone
numbers handy for calling friends, family, coworkers, and
clients.Additionally, most phones show the identity of the caller
based on the contacts application, including nicknames, photos, or
icons.
Free download pdf