Skip to content

ga-adi/cursor-adapter-lab

Repository files navigation

title type duration creator
Cursor Adapters - Grocery List
lab
1:25
name city
Drew Mahrt
NYC

Cursor Adapters - Grocery List

Introduction

Note: This can be a pair programming activity or done independently.

In this lab, you will be displaying a list of grocery items from a SQLite database using a CursorAdapter. Each grocery item has a name, description, price, and type. On this screen, you will only be showing the name of each item.

Exercise

Requirements

  • Extend and complete the SQLiteOpenHelper class to query the database for all of the grocery items
  • Make a ListView to display the grocery items
  • Use a CursorAdapter to display the queried grocery items

Bonus:

  • Create a custom layout for the ListView item to show more info from the database

Starter code

The starter-code folder contains an Android project with the following:

  • A MainActivity.java file that prepopulates the database

Deliverable

The screenshot below shows what the app should look like.

Bonus

  • Create a Detail View activity for your list
  • Your Detail View activity should be called via an Intent in an OnItemClickListener()
  • Your Detail View should render individual data about each item in your table:
    • ITEM_NAME
    • DESCRIPTION
    • PRICE
    • TYPE
Database Table Syntax
CREATE TABLE SHOPPING_LIST(_id INTEGER PRIMARY KEY AUTOINCREMENT, 
    ITEM_NAME TEXT, 
    DESCRIPTION TEXT, 
    PRICE TEXT, 
    TYPE TEXT);

Additional Resources

Creative Commons Non-Commercial License Released under the Creative Commons Non-Commercial License

About

[sql, sqlite, android]

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages