It's not as much beautiful as I liked, but it works.
Is there anyway to use AG implementation to read the cursor with all fields and retrieve the object? I've used "read" to do the magic, but I didn't like it.
public Collection<T> readSorted(EnumSort enumSort) {
String tableName = getTableName();
String fieldName = getIdFieldName();
String sql = "SELECT %s FROM %s ORDER BY %s %s";
if (enumSort == EnumSort.ASCENDING) {
sql = String.format(sql, fieldName, tableName, fieldName, "ASC");
} else {
sql = String.format(sql, fieldName, tableName, fieldName, "DESC");
}
Collection<T> collection = new ArrayList<T>();
SQLiteDatabase database = this.getReadableDatabase();
Cursor cursor = database.rawQuery(sql, new String[]{});
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
collection.add(this.read(cursor.getInt(0)));
}
return collection;
}