|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectContentProvider
org.hermit.android.provider.TableProvider
public class TableProvider
This class is a base for content providers which provide access to table-organized data in an SQL database.
Typically, this is used by creating a subclass which is empty
other than providing an appropriate schema to this class's constructor.
The bulk of the work in creating a content provider is in creating
the schema, a subclass of DbSchema
.
Constructor Summary | |
---|---|
TableProvider(DbSchema schema)
Create an instance of this content provider. |
Method Summary | |
---|---|
int |
delete(Uri uri,
java.lang.String where,
java.lang.String[] whereArgs)
A request to delete one or more rows. |
protected DatabaseHelper |
getHelper()
Get the database helper which this content provider will use. |
protected DbSchema |
getSchema()
Get the database schema. |
protected TableSchema |
getTableSchema(java.lang.String name)
Get the schema for a specified table. |
java.lang.String |
getType(Uri uri)
Return the MIME type of the data at the given URI. |
Uri |
insert(Uri uri,
ContentValues initValues)
Implement this to insert a new row. |
boolean |
onCreate()
Called when the provider is being started. |
protected void |
onInsert(Uri uri,
TableSchema table,
ContentValues initValues)
This method is called prior to processing an insert; it is called after TableSchema.onInsert(ContentValues) . |
Cursor |
query(Uri uri,
java.lang.String[] projection,
java.lang.String where,
java.lang.String[] whereArgs,
java.lang.String sortOrder)
Receives a query request from a client in a local process, and returns a Cursor. |
protected Cursor |
queryItem(TableSchema t,
java.lang.String[] projection,
long id)
Query for a specified item within a table. |
protected Cursor |
queryItem(TableSchema t,
java.lang.String[] projection,
java.lang.String id)
Query for a specified item within a table. |
protected Cursor |
queryItems(TableSchema t,
java.lang.String[] projection,
java.lang.String where,
java.lang.String[] whereArgs,
java.lang.String sortOrder)
Query for items within a table. |
int |
update(Uri uri,
ContentValues values,
java.lang.String where,
java.lang.String[] whereArgs)
Update a content URI. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TableProvider(DbSchema schema)
schema
- Structure defining the database schema.Method Detail |
---|
public boolean onCreate()
protected DbSchema getSchema()
protected TableSchema getTableSchema(java.lang.String name) throws java.lang.IllegalArgumentException
name
- The name of the table we want.
java.lang.IllegalArgumentException
- No such table.protected DatabaseHelper getHelper()
Subclasses may override this to provide a smarter database
helper; for example, to implement a smarter database upgrade
process. See DatabaseHelper
.
public java.lang.String getType(Uri uri)
uri
- The URI to query.
public Cursor query(Uri uri, java.lang.String[] projection, java.lang.String where, java.lang.String[] whereArgs, java.lang.String sortOrder)
uri
- The URI to query. This will be the full URI
sent by the client; if the client is requesting
a specific record, the URI will end in a record
number that the implementation should parse and
add to a WHERE or HAVING clause, specifying that
_id value.projection
- The list of columns to put into the cursor.
If null all columns are included.where
- A selection criteria to apply when filtering
rows. If null then all rows are included.whereArgs
- You may include ?s in selection, which will
be replaced by the values from selectionArgs,
in order that they appear in the selection.
The values will be bound as Strings.sortOrder
- How the rows in the cursor should be sorted.
If null then the provider is free to define the
sort order.
protected Cursor queryItem(TableSchema t, java.lang.String[] projection, long id)
t
- The schema for the table to query.projection
- The list of columns to put into the cursor.
If null all columns are included.id
- The ID of the item we want.
protected Cursor queryItem(TableSchema t, java.lang.String[] projection, java.lang.String id)
t
- The schema for the table to query.projection
- The list of columns to put into the cursor.
If null all columns are included.id
- The ID of the item we want, as a String.
protected Cursor queryItems(TableSchema t, java.lang.String[] projection, java.lang.String where, java.lang.String[] whereArgs, java.lang.String sortOrder)
t
- The schema for the table to query.projection
- The list of columns to put into the cursor.
If null all columns are included.where
- A selection criteria to apply when filtering
rows. If null then all rows are included.whereArgs
- You may include ?s in selection, which will
be replaced by the values from selectionArgs,
in order that they appear in the selection.
The values will be bound as Strings.sortOrder
- How the rows in the cursor should be sorted.
If null then the provider is free to define the
sort order.
protected void onInsert(Uri uri, TableSchema table, ContentValues initValues)
TableSchema.onInsert(ContentValues)
. Subclasses
can use this to carry out additional processing.
uri
- The content:// URI of the insertion request.table
- The schema of the table we're inserting into.initValues
- A set of column_name/value pairs to add to
the database.public Uri insert(Uri uri, ContentValues initValues)
uri
- The content:// URI of the insertion request.initValues
- A set of column_name/value pairs to add to
the database.
public int delete(Uri uri, java.lang.String where, java.lang.String[] whereArgs)
uri
- The full URI to delete, including a row ID
(if a specific record is to be deleted).where
- An optional restriction to apply to rows when
deleting.whereArgs
- You may include ?s in where, which will
be replaced by the values from whereArgs.
SQLException
- Database error.public int update(Uri uri, ContentValues values, java.lang.String where, java.lang.String[] whereArgs)
uri
- The URI to update. This can potentially have a
record ID if this is an update request for a
specific record.values
- A Bundle mapping from column names to new column
values (NULL is a valid value).where
- An optional restriction to apply to rows when
updating.whereArgs
- You may include ?s in where, which will
be replaced by the values from whereArgs.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |