0
嗨,大家好我有一個擁有經緯度的數據庫。我想把我的數據庫中的值(緯度和經度)放到我的變量TUJUAN
。我試着用這個代碼,但我不知道如何從我的數據庫查詢。這裏是我的代碼如何從SqLite獲取經度和緯度
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
}
請不要在UI線程上執行阻塞操作。 –