I want to get latitude and longitude data from sqlite database.
So i use this code below, but there is a problem in getListAdapter()
. It say that i must create 'getListAdapter()
' method. I'm searching on the net, but there is no example for getListAdapter()
method.
Can you fix my code. So if i click the item it will give me the lat and long data from my database.
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
//TODO Auto-generated method stub
String selectedItem = (String) getListAdapter().getItem(position);
String query = "SELECT lat, long FROM hoteltbl WHERE name = '" + selectedItem + "'";
SQLiteDatabase dbs = dbHotelHelper.getReadableDatabase();
Cursor result = dbs.rawQuery(query, null);
result.moveToFirst();
double lat = result.getDouble(result.getColumnIndex("lat"));
double longi = result.getDouble(result.getColumnIndex("long"));
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?f=d&saddr=&daddr="+lat+","+longi));
startActivity(intent);
}
By the way, this is the problem from my previous question