Android Tutorial

(avery) #1
Android Tutorial 343

 Finally,we provide custom implementations of the methods for Simple
CursorAdapter .CursorToString Converter and FilterQuery Provider to
allow the AutoComplete TextView to bind directly to the internal SQLite
database table called pet_types (middle), and change the AutoComplete
TextView behavior to match all substrings, not only the beginning of the
word. Although we won’t go into detail about this in the subsequent text,
check out the sample code for more information on the specific details of
implementation.

First, we need to decide where we are going to get our photos. We
can take pictures with the built-in camera and access those, but for
simplicity’s sake with the emulator (which can only take “fake
pictures”), it is easier if we download those cute, fuzzy pictures
from the browser onto the SD card and access them that way.

Locating Content on the Android System Using URIs

Most access to content providers comes in the form of queries: a
list of contacts, a list of bookmarks, a list of calls, a list of pictures,
and a list of audio files. Applications make these requests much as
they would access a database, and they get the same type of
structured results. The results of a query are often iterated through
using a cursor. However, instead of crafting queries, we use URIs.

You can think of a URI as an “address” to the location where
content exists. URI addresses are hierarchical. Most content
providers, such as the Contacts and the Media Store, have URI
addresses predefined. For example, to access images the External
Media Device (also known as the SD card), we use the following
URI defined in the Media Store.Images.Media class:

Uri mMedia = Media.EXTERNAL_CONTENT_URI;

Free download pdf