I have a list with onItemClickListener. In list are date and place. I would like to pass the place (when is clicked) to database handler and then in new activity get all data with same place.
I'm not quite good in android so I'm asking is it possible to do that? And how to pass this variable with place name into dbHandler?
here is my onItemClickListener
mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(DisplayLogsByPlace.this, LogsList.class);
startActivity(intent);
}
});
And this is my dbHandler in which I would call this variable
public ArrayList<Logs> getAllLogsWithSamePlace(String place) {
ArrayList<Logs> logPlaceList = new ArrayList<Logs>();
String selectQuery = "SELECT * FROM " + TABLE_LOGS + " WHERE " + KEY_PLACE + "=" + place;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
...
}
return logPlaceList;
}
Aucun commentaire:
Enregistrer un commentaire