The data model

Content providers expose their data as a simple table on a database model, where each row is a record and each column is data of a particular type and meaning. For example, information about people and their phone numbers might be exposed as follows:

_ID NUMBER NUMBER_KEY LABEL

13 (425) 555 6677 425 555 6677 Kirkland office 44 (212) 555-1234 212 555 1234 NY apartment

NAME TYPE

Bully Pulpit TYPE_WORK Alan Vain type home

45

(212) 555-6657

212 555 6657

Downtown office

Alan Vain

TYPE_MOBILE

53

201.555.4433

201 555 4433

Love Nest

Rex Cars

TYPE_HOME

Every record includes a numeric _id field that uniquely identifies the record within the table. IDs can be used to match records in related tables — for example, to find a person's phone number in one table and pictures of that person in another.

A query returns a Cursor object that can move from record to record and column to column to read the contents of each field. It has specialized methods for reading each type of data. So, to read a field, you must know what type of data the field contains. (There's more on query results and Cursor objects later.)

0 0

Post a comment