0

大家好,我有一个经纬度数据库。我想将这些值(纬度和经度)从我的数据库放到我的变量TUJUAN中。我尝试使用此代码,但我不知道如何从我的数据库中查询.. 这是我的代码

public class Arahkan extends FragmentActivity{
static public LatLng TUJUAN;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.arahkan);

    DataBaseHelper myDbHelper = new DataBaseHelper(
            this.getApplicationContext());
    myDbHelper = new DataBaseHelper(this);

    try {
        myDbHelper.createDataBase();
    } catch (IOException ioe) {
        throw new Error("Unable to create database");
    }

    // Open the database
    try {
        myDbHelper.openDataBase();
    } catch (SQLException sqle) {
        sqle.printStackTrace();
    }


    TextView arahkantext = (TextView) findViewById(R.id.text_arah2);

    String tampilarah = getIntent().getExtras().getString("key");
    if(tampilarah.equalsIgnoreCase("Balong Dalem")){
        tempat="Balong Dalem";
    }
    if(tampilarah.equalsIgnoreCase("Curug Bangkong")){
        tempat="CUrug Bangkong"
    }
           .........
           Cursor cur = db.rawQuery(
       "SELECT latlng FROM data WHERE nama_tempat='"  + tempat +  "';", null);  I DONT KNOW IN THIS LINE
            TUJUAN = new LatLng(???); ///  I DONT KNOW IN THIS LINE

}

4

1 回答 1

0

如何存储您的 LatLng?您应该存储这两个值(纬度和经度),以便您可以基于这些值创建一个新的 LatLng:

c.moveToFirst();
maCourse = new LatLng(c.getInt(0), c.getInt(1);

假设您的第一个商店纬度,然后经度如果我必须将您链接到一个关于数据库的好教程,我会说这个:http ://www.vogella.com/articles/AndroidSQLite/article.html

于 2013-06-01T13:10:14.723 回答