0

I am doing a Map application in Android using SQLite to store and retrieve data. So I create a table to store Latitude and Longtitude but I do not know how to retrieve the Latitude and Longtitude values from SQLite to bind them to Latitude and Longtitude values in the map activity.

Can anyone help me?

forsvarir
  • 10,749
  • 6
  • 46
  • 77
DienTrinh
  • 73
  • 1
  • 3
  • 7

1 Answers1

2

Use this as a start:

    SQLiteDatabase db = openOrCreateDatabase("my_locations.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
    String[] columns = new String[]{"latitude", "longitude"};
    String[] name = new String[]{"DienTringh"};
    Cursor c = db.query("location", columns, "name=?", name, null, null, null);
    String latitude = c.getString(0);
    String longitude = c.getString(1);
Aleadam
  • 40,203
  • 9
  • 86
  • 108