开发者

How to retrieve data from SQLite table in Android

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜