Reputation: 115
Guys at this time i want to ask HOW TO GET SPECIFIC DATA FROM DATABASE SQLITE THEN SHOW IT IN A TEXTVIEW in SEARCH ACTIVITY
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;
PLEASE HELP ME!, thx B4 :)
Upvotes: 1
Views: 352
Reputation: 133560
I don't know what you mean by specific data.
You need to call the function that returns a list and display data in textview based on index position
In Activity
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());
Upvotes: 1