Method getAllContacts
Method getAllContacts
(Fig. 8.55) uses SqLiteDatabase
’s query method (lines 83–84) to retrieve a Cursor
that provides access to the IDs and names of all the contacts in the database. The arguments are:
• the name of the table to query.
• a String
array of the column names to return (the _id
and name
columns here)—null
returns all columns in the table, which is generally a poor programming practice, because to conserve memory, processor time and battery power, you should obtain only the data you need.
• a SQL WHERE
clause (without the keyword WHERE
), or null
to return all rows.
• a String
array of arguments to be substituted into the WHERE
clause wherever ?
is used as a placeholder for an argument value, or null
if there ...
Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.