i have a problem
Im wanna order my register by date for example:
- 01/01/2014
- 02/01/2014
- 03/01/2014
A have a DATETIME field:
fechacobro DATETIME DEFAULT CURRENT_DATE
I insert my register:
FUNCTION
private ContentValues contvaladdcobro(String fechacobro){
ContentValues valor = new ContentValues();
valor.put("fechacobro", fechacobro);
return valor;
}
public void **addcobro**(String fechacobro){
try {
db.insert("cobranza", null, contvaladdcobro(fechacobro));
Log.i("dato insertado: ","Exitoso");
}catch (Exception e){
Log.i("error al insertar",e.toString());
}
}
INSERTING
sqlite.addcobro("01/01/2014");
sqlite.addcobro("02/01/2014");
sqlite.addcobro("03/01/2014");
here all is OK, but when i want show my registers, use this funtion:
public Cursor showregisters(){
String[] columnas = new String[]{"fechacobro"};
return db.query("cobranza",columnas,null,"date(fechacobro)",null,null,null);
}
I CALL THIS FUNTION
Cursor cursor = sqlite.showregisters();
cursor.movetofirts;
do{
Log.i("mensaje",cursor.getString(0));
}while(cursor.movetonext);
My result is just:
01/01/2014
Someone can help me?
Aucun commentaire:
Enregistrer un commentaire