此时的家伙我想询问如何从数据库SQLITE中获取特定数据,然后在搜索活动的TEXTVIEW中显示
public ArrayList<Sma> getPoint(String name)
{
ArrayList <Sma> point = new ArrayList<Sma>();
String selectQuery = "SELECT latitude_sma, longtitude_sma FROM sma WHERE nama_sma ='" + name + "'"; >> FROM HERE I JUST WANT TO SHOW latitude_sma, and longtitude_sma IN A TEXTVIEW
open();
Cursor c = database.rawQuery(selectQuery, null);
if (c.moveToFirst()) {
do {
Sma sekolah = new Sma();
sekolah.setLatitude(c.getString(c.getColumnIndex(latitude_sma)));
sekolah.setLongitude(c.getString(c.getColumnIndex(longtitude_sma)));
point.add(sekolah);
}
while (c.moveToNext());
}
return point;
请帮助我!,B4:)
答案 0 :(得分:1)
我不知道具体数据的含义。
您需要调用返回列表的函数,并根据索引位置
在textview中显示数据活动
Database db = new Database(this);
ArrayList<Sma> list = db.getPoint("your name");
TextView tv = (TextView) findViewById(R.id.textView1);
tv.setText(list.get(0).getLatitude().toString());