Application Find a Friend

Companies. Click here for terms of use.

Key Skills & Concepts

• Create a SQLite database

• Create a custom Content Provider

• Retrieve items from a database and pass them to a Google Maps Overlay

This is the final chapter in which you will create an application, but it will be one of the largest applications introduced in this book. I will cover a couple of topics that you have not encountered thus far, and you will use the skills introduced in those topics to create a very robust application.

In this chapter, you will learn how to create SQLite databases on your Android Emulator. I will show you how to read, write, and delete data within your custom database. This process includes creating and using your own custom Content Provider to work with your database. Then, you will take the data that is stored in your database and write it out to a Google Maps Overlay. While you have worked with Google Maps previously in this book, you have not yet used an Overlay. You use Google Maps Overlays to draw shapes and write text on your map, resulting in very informative maps.

In this project, you will create a two-part application. The first part of the application will allow the user to enter "friends" into a mobile database. (A friend consists of a name and a geographic coordinate location.) The user will be able to add, modify, and delete friends.

The second part of the application will include a menu item. When the user selects this menu item, the application will display a Google Map. What make this different from the other Google Map you created in Chapter 9 is that this map will include a Google Maps Overlay, which enables you to write names, give information, and draw items on top of a Google Maps tile.

To begin, create a new Android Project within Eclipse named FindAFriend, using the settings shown in the following illustration.

£ New Android Project

:=. LBJEHEI

New Android Project

a

Creates a new Android Project resource,

Project name: FindAFriend Content?

O) Create new project in workspace ■ ■ Create project from existing source F71 Use default location

Project name: FindAFriend Content?

O) Create new project in workspace ■ ■ Create project from existing source F71 Use default location

Location; | C:/Users/JFDiMarzio/workspace/FindAFriend | I Browse,

Properties

Package name: android_programmers_guide.FindAFriend

Activity name: FindAFriend Application name: FindAFriendj

While you should be fairly comfortable creating Android applications by now, you will have a little bit of help creating this project. Google includes in the Android SDK an application called NotePad, a simple interface that lets you store, modify, and delete "notes" in a database. You are going to modify some of this sample code to create the interface for your Friends database.

If you want to see how Google NotePad works, load the project into Eclipse and run it in your Android Emulator before you move on. You will begin to modify this code shortly, but first, in the following section, you will create your first SQLite database.

0 0

Post a comment