0
In my adapter I putExtra the id and then in the details of the activity I want to get the id and through the id go to search in the database the information. for example name
Myrecycleradapter
holder.detalhes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(context, DetalhesPonto.class);
i.putExtra("id_detalhe", ponto1.getId());
context.startActivity(i);
}
});
}
Method of the database
public List<PontoDeInteresse> getPontoDeInteresseDetalhes(long id) {
List<PontoDeInteresse> data1 = new ArrayList<>();
SQLiteDatabase db1 = this.getWritableDatabase();
Cursor c1 = db1.rawQuery("SELECT * FROM " + TABLE_NAME_PONTO + " WHERE " + FIRST_COLUMN_PONTO + "= ?", new String[]{Long.toString(id)});
StringBuffer stringBuffer1 = new StringBuffer();
PontoDeInteresse ponto1 = null;
while (c1.moveToNext()) {
ponto1 = new PontoDeInteresse();
//int id = c1.getInt(c1.getColumnIndexOrThrow("id_ponto"));
String name = c1.getString(c1.getColumnIndexOrThrow("nome"));
String desc = c1.getString(c1.getColumnIndexOrThrow("descricao"));
String city = c1.getString(c1.getColumnIndexOrThrow("id_cidade"));
String latitude = c1.getString(c1.getColumnIndexOrThrow("latitude"));
String longitude = c1.getString(c1.getColumnIndexOrThrow("longitude"));
String rat = c1.getString(c1.getColumnIndexOrThrow("rating"));
String cate = c1.getString(c1.getColumnIndexOrThrow("id_categoria"));
//ponto1.setId(id);
ponto1.setNome(name);
ponto1.setDescricao(desc);
ponto1.setCidade(city);
ponto1.setLatitude(latitude);
ponto1.setLongitude(longitude);
ponto1.setRating(rat);
ponto1.setCategoria(cate);
stringBuffer1.append(ponto1);
// stringBuffer.append(dataModel);
data1.add(ponto1);
} return data1;
}