I'm completely new in using sqlite databases with android. I want to get value from database using following SQL statement:
"SELECT description FROM games WHERE _id =" + categoryID
Where categoryID is the position of clicked element in listView (which is also the value of _id column).
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
String categoryID = new Integer(position).toString();
final String SELECT_FROM = "SELECT description " + "FROM games "
+ "WHERE _id = " + categoryID;
database.query(SELECT_FROM);
Intent intent = new Intent();
intent.setClass(SqliteDbActivity.this, ViewAction.class);
Bundle b = new Bundle();
b.putString("categoryID", SELECT_FROM);
intent.putExtras(b);
startActivity(intent);
}
});
I know that I should use database.query() but how should I correctly write the previous sql statement to get value?
Table looks like:
_id description name
1 some1 name1
2 some2 name2
3 some3 name3
Please, help.
Adapterare you using for yourListView?ArrayAdapter<String>