开发者

How to retrieve data from SQLite table in Android

开发者 https://www.devze.com 2023-03-04 04:43 出处:网络
I am doing a Map application in Android using SQ开发者_Python百科Lite 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 an

I am doing a Map application in Android using SQ开发者_Python百科Lite 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?


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号