com.todoroo.andlib.data
Class ContentResolverDao<TYPE extends AbstractModel>

java.lang.Object
  extended by com.todoroo.andlib.data.ContentResolverDao<TYPE>
Type Parameters:
TYPE - model type
Direct Known Subclasses:
MetadataApiDao, StoreObjectApiDao, TaskApiDao

public class ContentResolverDao<TYPE extends AbstractModel>
extends java.lang.Object

DAO for reading and writing values from an Android ContentResolver

Author:
Tim Su

Constructor Summary
ContentResolverDao(java.lang.Class<TYPE> modelClass, android.content.Context context, android.net.Uri baseUri)
           
 
Method Summary
 int delete(long id)
          Delete specific item from the given table
 int deleteWhere(Criterion where)
          Delete by criteria
 TYPE fetch(long id, Property<?>... properties)
          Returns object corresponding to the given identifier
 TodorooCursor<TYPE> query(Query query)
          Query content provider
 boolean save(TYPE model)
          Create new or save existing model
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentResolverDao

public ContentResolverDao(java.lang.Class<TYPE> modelClass,
                          android.content.Context context,
                          android.net.Uri baseUri)
Method Detail

delete

public int delete(long id)
Delete specific item from the given table

Parameters:
id -
Returns:
number of rows affected

deleteWhere

public int deleteWhere(Criterion where)
Delete by criteria

Parameters:
where -
Returns:
number of rows affected

query

public TodorooCursor<TYPE> query(Query query)
Query content provider

Parameters:
query -
Returns:

save

public boolean save(TYPE model)
Create new or save existing model

Parameters:
model -
Returns:
true if data was written to the db, false otherwise

fetch

public TYPE fetch(long id,
                  Property<?>... properties)
Returns object corresponding to the given identifier

Parameters:
database -
table - name of table
properties - properties to read
id - id of item
Returns:
null if no item found