Class Overview
Caches the contents of a cursor into a Map of String->ContentValues and optionally
keeps the cache fresh by registering for updates on the content backing the cursor. The column of
the database that is to be used as the key of the map is user-configurable, and the
ContentValues contains all columns other than the one that is designated the key.
The cursor data is accessed by row key and column name via getValue().
Summary
| Public Constructors |
|
|
ContentQueryMap(Cursor cursor, String columnNameOfKey, boolean keepUpdated, Handler handlerForUpdateNotifications)
Creates a ContentQueryMap that caches the content backing the cursor
|
| Public Methods |
|
synchronized
void
|
close()
|
|
synchronized
Map<String, ContentValues>
|
getRows()
|
|
synchronized
ContentValues
|
getValues(String rowName)
Access the ContentValues for the row specified by rowName
|
|
void
|
requery()
Requeries the cursor and reads the contents into the cache
|
|
void
|
setKeepUpdated(boolean keepUpdated)
Change whether or not the ContentQueryMap will register with the cursor's ContentProvider
for change notifications.
|
| Protected Methods |
|
void
|
finalize()
Called by the virtual machine when there are no longer any (non-weak)
references to the receiver.
|
|
[Expand]
Inherited Methods |
From class java.util.Observable
|
synchronized
void
|
addObserver(Observer observer)
Adds the specified Observer to the list of observers.
|
|
synchronized
void
|
clearChanged()
Clears the changed flag for this Observable.
|
|
synchronized
int
|
countObservers()
Returns the number of Observers in the list of observers.
|
|
synchronized
void
|
deleteObserver(Observer observer)
Removes the specified Observer from the list of observers.
|
|
synchronized
void
|
deleteObservers()
Removes all Observers from the list of observers.
|
|
synchronized
boolean
|
hasChanged()
Returns the changed flag for this Observable.
|
|
void
|
notifyObservers()
If hasChanged() returns true, calls the update() method for
every Observer in the list of observers using null as the argument.
|
|
void
|
notifyObservers(Object data)
If hasChanged() returns true, calls the update() method for
every Observer in the list of observers using the specified argument.
|
|
synchronized
void
|
setChanged()
Sets the changed flag for this Observable.
|
|
From class java.lang.Object
|
Object
|
clone()
Returns a new instance of the same class as the receiver, whose slots
have been filled in with the values in the slots of the receiver.
|
|
boolean
|
equals(Object o)
Compares the argument to the receiver, and returns true if they represent
the same object using a class specific comparison.
|
|
void
|
finalize()
Called by the virtual machine when there are no longer any (non-weak)
references to the receiver.
|
|
final
Class<? extends Object>
|
getClass()
Returns the unique instance of java.lang.Class which represents the class
of the receiver.
|
|
int
|
hashCode()
Returns an integer hash code for the receiver.
|
|
final
void
|
notify()
Causes one thread which is wait ing on the receiver to be
made ready to run.
|
|
final
void
|
notifyAll()
Causes all threads which are wait ing on the receiver to
be made ready to run.
|
|
String
|
toString()
Returns a string containing a concise, human-readable description of the
receiver.
|
|
final
void
|
wait(long time, int frac)
Causes the thread which sent this message to be made not ready to run
either pending some change in the receiver (as indicated by
notify or notifyAll) or the expiration of
the timeout.
|
|
final
void
|
wait(long time)
Causes the thread which sent this message to be made not ready to run
either pending some change in the receiver (as indicated by
notify or notifyAll) or the expiration of
the timeout.
|
|
final
void
|
wait()
Causes the thread which sent this message to be made not ready to run
pending some change in the receiver (as indicated by notify
or notifyAll).
|
|
Public Constructors
public
ContentQueryMap
(Cursor cursor, String columnNameOfKey, boolean keepUpdated, Handler handlerForUpdateNotifications)
Creates a ContentQueryMap that caches the content backing the cursor
Parameters
| cursor
| the cursor whose contents should be cached |
| columnNameOfKey
| the column that is to be used as the key of the values map |
| keepUpdated
| true if the cursor's ContentProvider should be monitored for changes and
the map updated when changes do occur |
| handlerForUpdateNotifications
| the Handler that should be used to receive
notifications of changes (if requested). Normally you pass null here, but if
you know that the thread that is creating this isn't a thread that can receive
messages then you can create your own handler and use that here.
|
Public Methods
public
synchronized
void
close
()
public
synchronized
ContentValues
getValues
(String rowName)
Access the ContentValues for the row specified by rowName
Parameters
| rowName
| which row to read |
Returns
- the ContentValues for the row, or null if the row wasn't present in the cursor
public
void
requery
()
Requeries the cursor and reads the contents into the cache
public
void
setKeepUpdated
(boolean keepUpdated)
Change whether or not the ContentQueryMap will register with the cursor's ContentProvider
for change notifications. If you use a ContentQueryMap in an activity you should call this
with false in onPause(), which means you need to call it with true in onResume()
if want it to be kept updated.
Parameters
| keepUpdated
| if true the ContentQueryMap should be registered with the cursor's
ContentProvider, false otherwise
|
Protected Methods
protected
void
finalize
()
Called by the virtual machine when there are no longer any (non-weak)
references to the receiver. Subclasses can use this facility to guarantee
that any associated resources are cleaned up before the receiver is
garbage collected. Uncaught exceptions which are thrown during the
running of the method cause it to terminate immediately, but are
otherwise ignored.
Note: The virtual machine assumes that the implementation in class Object
is empty.