SQLite GoogleMaps UNIT5
SQLite GoogleMaps UNIT5
import android.database.sqlite.SQLiteDatabase;
SQLiteDatabase myDatabase;
myDatabase = openOrCreateDatabase
("my_sqlite_database.db" ,
SQLiteDatabase.CREATE_IF_NECESSARY , null);
Creating Tables
Create a static string containing the SQLite CREATE
statement, use the execSQL( ) method to execute it.
import android.content.ContentValues;
ContentValues values = new ContentValues( );
values.put("firstname" , "J.K.");
values.put("lastname" , "Rowling");
long newAuthorID = myDatabase.insert("tbl_authors" , "" ,
values);
update( )
int update(String table, ContentValues values, String
whereClause, String[ ]
whereArgs)
<uses-sdk
android:minSdkVersion="10" / >
<uses-permission
android:name="android.permission
.INTERNET"/>
<application
android:icon="@drawable/
ic_launcher"
android:label="@string/
app_name" >
<uses-library
android:name="com.google.an
droid.maps" / >
<activity
android:label="@string/app_name"
android:name=".GoogleMapActivity" >
<intent-filter >
<action
android:name="android.intent.action.
5. main.xml: replace with this
codes
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
xmlns:android="
http://schemas.android.com/apk/res/android"
android:id="@+id/mymap"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="Enter Your API Key"
/>
6. Getting API Key:
1. Go to a website,
http://code.google.com/android/add-
ons/google-apis
2. Click on Maps API Key Signup
6.3. Enter your MD5 fingerprint. (Scroll down a
bit)
6.4. To get MD5
fingerprint
6.4.1. In Eclipse, go to Window -> Preferences -> Android -
> Build -> Default debug keystore -> Copy the path
6.4.2. In Windows Explorer, go to Java installed folder, e.g. c:\
Program Files (x86)\Java -> jre6 -> bin -> keystore.exe
• 6.4.3. After you found out keystore.exe, open cmd, and
then go to folder where keystore located.
keytool - l i s t - a l i a s androiddebugkey -keystore "C:\
User s \ ko s a l\ .a ndroi d \ debug.k eystore" - st orepass
android -keypass android
xmlns:android="
http://schemas.android.com/apk/res/android"
android:id="@+id/mymap"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="eNtEr_y0uR_Ap1_kEy_HeRe"
/>
8. In Java, you must extends MapActivity instead of Activity:
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
@Override
protected boolean isRouteDisplayed() {
/ / TODO Auto-generated method stub
return f a l s e ;
}
}
• Run the App with the AVD targeting Google
API