Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/com/activeandroid/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public final void delete() {
.notifyChange(ContentProvider.createUri(mTableInfo.getType(), mId), null);
}

public final Long save() {
public Long save() {
final SQLiteDatabase db = Cache.openDatabase();
final ContentValues values = new ContentValues();

Expand Down Expand Up @@ -175,6 +175,14 @@ public static <T extends Model> T load(Class<T> type, long id) {
return (T) new Select().from(type).where(tableInfo.getIdName()+"=?", id).executeSingle();
}

public static <T extends Model> List<T> all(Class<T> type) {
return (List<T>) new Select().from(type).execute();
}

public static <T extends Model> T first(Class<T> type) {
return (T) new Select().from(type).executeSingle();
}

// Model population

public final void loadFromCursor(Cursor cursor) {
Expand Down