my question is how can I do that in a sqlite query the record appears with the date closest to the current, only one, I try to fill a recyclerView but only should appear the data with the closest date, so It is my method to show the data:
private List<RegistroAuto> ObtenerLista() {
SQLiteHelper base = new SQLiteHelper(getContext(),"Cartago.db",null,1);
SQLiteDatabase datos = base.getReadableDatabase();
List<RegistroAuto>lista= new ArrayList<>();
RegistroAuto registroAuto = null;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
Date date = new Date();
String fecha = simpleDateFormat.format(date);
Cursor cursor = datos.rawQuery("SELECT Marca,Placa,FecSoap,Modelo FROM tbl_regautosx",null);
while (cursor.moveToNext()){
registroAuto = new RegistroAuto();
registroAuto.setMarca(cursor.getString(0));
registroAuto.setPlaca(cursor.getString(1));
registroAuto.setFecSoap(cursor.getString(2));
registroAuto.setModelo(cursor.getString(3));
lista.add(registroAuto);
}
return lista;
}
works but only the one whose soat expiration date is closest (FecSoap) should appear, how can I do it, how do I propose the query or how do I compare them, in advance thanks?