As example:
class Abc {
public static String get_latest_updated_at(Class model, String where, Object... args) {
ColumnAlias[] alias = new ColumnAlias[1];
alias[0] = ColumnAlias.columnRaw("max(updated_at) as updated_at");
String query = "select max(updated_at) as updated_at from "+FlowManager.getTableName(model);
Cursor cursor = FlowManager.getDatabaseForTable(model).getWritableDatabase().rawQuery(query, null);
if(cursor.getCount() > 1)
return "";
cursor.moveToFirst();
return cursor.getString(cursor.getColumnIndex("updated_at"));
}
}
calling example:
Abc.get_latest_updated_at(Address.class, "")
//where by Address is model extending BaseModel
No comments:
Post a Comment