Live Folder Content Providers

Any Content Provider can provide the data displayed within a Live Folder. Live Folders use a standard set of column

> LiveFolders._ID A unique identifier used to indicate which item was selected if a user clicks the Live Folder list.

> LiveFolders.NAME The primary text, displayed in a large font. This is the only required column.

> LiveFolders.DESCRIPTION A longer descriptive field in a smaller font, displayed beneath the name column.

> LiveFolders.IMAGE An image displayed at the left of each item.

When displayed, a Live Folder will use these column names to extract data from your Content Provider for display.

Rather than renaming your Content Provider to suit the requirements of Live Folders, you should apply a projection that maps the required column names to columns used within your existing Content Provider, as shown in Listing 10-15.

ED0DO 09^14

Chewy Trewhella

Home

Mark Otway

Mark Otway

FIGURE 10-4

LISTING 10-15: Creating a projection to support a Live Folder

Available for download on final HashMap<String, Wrox.com new HashMap<String, liveFolderProjection.

liveFolderProjection liveFolderProjection liveFolderProjection

String> liveFolderProjection = String>(); put(LiveFolders._ID, KEY_ID + " AS " + LiveFolders._ID); put(LiveFolders.NAME,

KEY_NAME_COLUMN + " AS " + LiveFolders.NAME); put(LiveFolders.DESCRIPTION,

KEY_DESCRIPTION_COLUMN + " AS LiveFolders.DESCRIPTION); put(LiveFolders.IMAGE,

KEY_IMAGE_COLUMN + " AS " + LiveFolders.IMAGE);

SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); qb.setTables(MY_TABLES);

qb.setProjectionMap(LIVE_FOLDER_PROJECTION);

Only the ID and name columns are required; the image and description columns can be used or left unmapped as required.

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide


Post a comment