Sqlite does not sort the dates like other databases, mysql for example, I also had this problem in an application of mine, but I solved using "compareTo" in the class of my object.
Maybe it’s not the solution you need.
Call class
public class Call{
...
/**
* metodo para ordernar por data
* @param another Call classe de entrada para comparar
*/
@Override
public int compareTo(Call another) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
java.util.Date dateComparer, dateActual;
try {
dateActual = sdf.parse(this.getData());
dateComparer = sdf.parse(another.getData());
if (dateActual.before(dateComparer)) {
return Constants.SUCESS;
}
if (dateActual.after(dateComparer)) {
return Constants.ERROR;
}
} catch (ParseException e) {
e.printStackTrace();
}
return 0;
}
then I create a list and order:
private List<Call> listCalls(ResultSet resultset){
List<Call> calls = new ArrayList<Call>();
do {
Call item = new Call();
item._id = resultset.getString(Call.FIELD1);
calls.add(item);
} while (resultset.next());
...
Collections.sort(calls);
}
You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? Something needs to be improved?
– Maniero