0
I have a list, which shows all the data of the sqlite database, image path, latitude and longitude, but in the list only changes the image path, latitude and longitude always remains those of the first record.
public List<Foto> todasFotos(){
List<Foto> listaFotos = new ArrayList<Foto>();
SQLiteDatabase db = getReadableDatabase();
String sqlTodasFotos = "SELECT * FROM imagens";
Cursor c = db.rawQuery(sqlTodasFotos,null);
if (c.moveToNext()) {
do {
Foto foto = new Foto();
foto.setId(c.getInt(0));
foto.setCaminho_foto(c.getString(1));
foto.setLatitude(c.getDouble(2));
foto.setLongitude(c.getDouble(3));
listaFotos.add(foto);
} while (c.moveToNext());
}
db.close();
return listaFotos;
}
Make sure the problem isn’t when you recorded the records.
– ramaral
I checked and it’s actually saving the same latitude and longitude for all the records, the weird one that was working yesterday... But thank you so much for the tip.
– Juliano Morche
Could you add how you do Insert? As @ramaral said, the problem may be when you saved!
– Thiago Luiz Domacoski
Try to get the Photo photo = new Photo(); from inside the looping
– Leonardo Dias
Try using this SQL:
SELECT COUNT(*) FROM imagens
and then checks the number that returns inc.getInt(0)
, this is the number of records in your bank.– Marco Giovanni
Juliano, have you solved your problem with the answer? Or do you need some more information?
– viana
I did, thank you very much !
– Juliano Morche