|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.todoroo.andlib.data.DatabaseDao<TYPE>
public class DatabaseDao<TYPE extends AbstractModel>
DAO for reading data from an instance of AbstractDatabase. If you
are writing an add-on for Astrid, you probably want to be using a subclass
of ContentResolverDao instead.
| Nested Class Summary | |
|---|---|
static interface |
DatabaseDao.ModelUpdateListener<MTYPE>
|
| Constructor Summary | |
|---|---|
DatabaseDao(java.lang.Class<TYPE> modelClass)
|
|
DatabaseDao(java.lang.Class<TYPE> modelClass,
AbstractDatabase database)
|
|
| Method Summary | |
|---|---|
void |
addListener(DatabaseDao.ModelUpdateListener<TYPE> listener)
|
boolean |
createNew(TYPE item)
Creates the given item. |
boolean |
delete(long id)
Delete the given id |
int |
deleteWhere(Criterion where)
Delete all matching a clause |
TYPE |
fetch(long id,
Property<?>... properties)
Returns object corresponding to the given identifier |
Table |
getTable()
Gets table associated with this DAO |
boolean |
persist(TYPE item)
Save the given object to the database. |
TodorooCursor<TYPE> |
query(Query query)
Construct a query with SQL DSL objects |
TodorooCursor<TYPE> |
rawQuery(java.lang.String selection,
java.lang.String[] selectionArgs,
Property<?>... properties)
Construct a query with raw SQL |
boolean |
saveExisting(TYPE item)
Saves the given item. |
void |
setDatabase(AbstractDatabase database)
Sets database accessed by this DAO. |
int |
update(Criterion where,
TYPE template)
Update all matching a clause to have the values set on template object. |
int |
updateMultiple(android.content.ContentValues values,
Criterion criterion)
Updates multiple rows of the database based on model set values |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DatabaseDao(java.lang.Class<TYPE> modelClass)
public DatabaseDao(java.lang.Class<TYPE> modelClass,
AbstractDatabase database)
| Method Detail |
|---|
public Table getTable()
public void setDatabase(AbstractDatabase database)
database - public void addListener(DatabaseDao.ModelUpdateListener<TYPE> listener)
public TodorooCursor<TYPE> query(Query query)
query -
public TodorooCursor<TYPE> rawQuery(java.lang.String selection,
java.lang.String[] selectionArgs,
Property<?>... properties)
properties - selection - selectionArgs -
public TYPE fetch(long id,
Property<?>... properties)
database - table - name of tableproperties - properties to readid - id of item
public boolean delete(long id)
database - id -
public int deleteWhere(Criterion where)
where - predicate for deletion
public int update(Criterion where,
TYPE template)
Example (updates "joe" => "bob" in metadata value1): {code} Metadata item = new Metadata(); item.setValue(Metadata.VALUE1, "bob"); update(item, Metadata.VALUE1.eq("joe")); {code}
where - sql criteriatemplate - set fields on this object in order to set them in the db.
public boolean persist(TYPE item)
public boolean createNew(TYPE item)
database - table - table nameitem - item model
public boolean saveExisting(TYPE item)
database - table - table nameitem - item model
public int updateMultiple(android.content.ContentValues values,
Criterion criterion)
item - item modelcriterion -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||