|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.app.DataStore
public final class DataStore
A container for records of data, each identified by a unique integer value.
Applications can use one or more DataStores to store data that must persist across device reboots.
DataStores can either be local to the device, or 'synced' with the backend service.
A Datastore can be either 'private' or 'shared'.
DataStore modification
DataStores are modified by adding, updating and removing
records. When a modification is made, the DataStore's Last Modified time is updated.
| Field Summary | |
|---|---|
static int |
AUTO_SYNC_WAIT_FOR_CONFIRM
Deprecated. For internal use only. |
static boolean |
DEBUG_AUTO_SYNC
Deprecated. For internal use only. |
static boolean |
DEBUG_AUTO_SYNC_UID
Deprecated. For internal use only. |
static String |
DS_SCHEDULED_FOR_ACTIVATION
Deprecated. For internal use only. |
static int |
RECORD_FLAG_MASK
Deprecated. For internal use only. |
static int |
RECORD_MODIFIED
Deprecated. For internal use only. |
| Method Summary | |
|---|---|
int |
addRecord(byte[] data)
Add a new record with flags=0, return its number |
int |
addRecord(byte[] data,
int flags)
Deprecated. For internal use only. |
int |
addRecord(byte[] data,
int flags,
int uid)
Deprecated. For internal use only. |
static void |
allowAutoSyncToService(boolean flag)
Deprecated. For internal use only. |
boolean |
autoSync()
Returns information about whether this is an autosynced DataStore (i.e. a DataStore that will be synced with the service at regular intervals.) |
void |
autoSyncFromServiceDone()
Deprecated. For internal use only. |
static boolean |
autoSyncToService()
Deprecated. For internal use only. |
int |
binarySearch(Comparator inComparator,
byte[] inKey)
|
int |
binarySearch(int inUID)
|
static void |
broadcastAutoSyncDone()
Deprecated. For internal use only. |
int |
compareTo(Object o)
|
static DataStore |
createDataStore(String name)
|
static DataStore |
createDataStore(String name,
boolean autoSync)
|
static DataStore |
createSharedDataStore(String name)
Create a new shared DataStore by name. |
static DataStore |
createSharedDataStore(String name,
boolean autoSync)
|
static boolean |
dataStoresPendingActivation()
Deprecated. For internal use only. |
static void |
deleteDataStore(DataStore inDS)
|
static void |
deleteLocalDataStore(DataStore inDS)
Deprecated. For internal use only. |
static void |
deregisterListenerForAutoSyncDone(Listener inListener)
|
static void |
discardAllOnReboot()
Deprecated. For internal use only. |
boolean |
discardOnReboot()
|
void |
discardOnReboot(boolean flag)
|
void |
doneResolvingConflict()
|
static void |
dumpList()
Prints out the data stores for all applications to the system log. |
static void |
dumpList(Application app)
Prints out the data stores for the given application to the system log. |
static DataStore |
findDataStore(String name)
Locate a DataStore by name. |
static DataStore |
findSharedDataStore(String name)
Locate a shared DataStore by name. |
static void |
flattenStores()
Deprecated. For internal use only. |
static String[] |
getAllFullNames()
Deprecated. For internal use only. |
int |
getAutoSyncNextUID()
Deprecated. For internal use only. |
int |
getByteSize()
Returns the total number of bytes (including any additional bytes used by the internal structure of the DataStore) this DataStore and its records are occupying. |
int |
getBytesUsed()
Returns the total number of bytes actually representing record data in this DataStore. |
String |
getDBName()
|
String |
getFullName()
Returns the full name of the database (which will be slightly different than the name an app uses to find the database) |
int |
getLastModified()
Returns the time (in "Danger seconds", the number of seconds since January 1, 2000 GMT) at which the DataStore was last modified. |
long |
getLastModifiedMillis()
Returns the time (in milliseconds since January 1, 1970 GMT) at which the DataStore was last modified. |
int |
getLastSynced()
Returns the time (in Danger seconds) when the DataStore was last synced. |
long |
getLastSyncedMillis()
Returns the time (in milliseconds since January 1, 1970 GMT) when the DataStore was last synced. |
int |
getRecordCount()
Returns the number of records in the DataStore. |
byte[] |
getRecordData(int n)
Returns the byte array of the record with index n. |
byte[] |
getRecordDataByUID(int uid)
Returns the byte array of the record with the specified uid. |
int |
getRecordFlags(int n)
Deprecated. For internal use only. |
int |
getRecordIndexByUID(int uid)
Returns the index of the record with a given uid. |
byte[][] |
getRecords()
obtain an array of byte arrays for all records |
int |
getRecordUID(int n)
Returns the UID of the record with index n. |
int |
getVersion()
Returns the application defined version number of this DataStore. |
static Object |
initialize()
Deprecated. For internal use only. |
int |
insertRecord(byte[] data,
int index)
Insert a new record |
int |
insertRecord(byte[] data,
int index,
int flags)
Deprecated. For internal use only. |
int |
insertRecordSorted(Comparator inComparator,
byte[] inItem)
|
int |
insertRecordSorted(int inUID,
byte[] inItem)
|
boolean |
isRecordDirty(int n)
Checks whether the record with index n has been modified. |
static boolean |
journalReconcile(Object inKey,
String inName)
Deprecated. For internal use only. |
static void |
processBackingStoreResponse(BackingStoreTransaction bt)
Deprecated. For internal use only. |
static void |
recoverDataStores()
Deprecated. For internal use only. |
static void |
registerListenerForAutoSyncDone(Listener inListener)
|
void |
removeAllRecords()
Remove all records from the DataStore. |
void |
removeRecord(int n)
Removes the record with zero-based index n from the DataStore. |
void |
removeRecordByUID(int uid)
Finds the index of the record with the specified UID and calls removeRecord(int) for this
record. |
void |
removeRecordWithoutAutoSync(int n)
Deprecated. For internal use only. |
void |
setAutoSyncNotifyee(Listener inNotifyee)
Specifies the listener that should be sent an Event.EVENT_DATASTORE_RESTORED after this DataStore has been successfuly restored from the service. |
void |
setAutoSyncNotifyee(Listener inNotifyee,
Bundle bundle)
Deprecated. For internal use only. |
void |
setRecordData(int n,
byte[] data)
Replaces the data of the record with index n with the data of the provided byte array, sets the record's dirty flag, and updates the DataStore's last modified time. |
void |
setRecordData(int n,
byte[] data,
boolean makeDirty)
Replaces the data of the record with index n with the data of the provided byte array. |
void |
setRecordDataByUID(int uid,
byte[] data)
Replaces the data of the record with id uid with the data of the
provided byte array, sets the record's dirty flag, and updates the
DataStore's last modified time. |
void |
setRecordDataByUID(int uid,
byte[] data,
boolean makeDirty)
Deprecated. For internal use only. |
void |
setRecordDirty(int n,
boolean flag)
Sets or clears the Record Dirty flag of the record with index n. |
void |
setRecordFlags(int n,
int flags)
Deprecated. For internal use only. |
void |
setRecordFlagsByUID(int uid,
int flags)
Deprecated. For internal use only. |
void |
setRecordUID(int n,
int uid)
Deprecated. For internal use only. |
void |
setVersion(int inVersion)
Allows applications to specify a version number to this DataStore. |
void |
sort(Comparator comparator)
|
void |
sortByUID()
|
void |
swapRecords(int this_rec,
int that_rec)
Exchange the data and flags of this_rec with that_rec. |
void |
updateLastModified()
Deprecated. For internal use only. |
void |
updateLastSynced()
Deprecated. For internal use only. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DS_SCHEDULED_FOR_ACTIVATION
public static final int RECORD_MODIFIED
public static final int AUTO_SYNC_WAIT_FOR_CONFIRM
public static final int RECORD_FLAG_MASK
public static final boolean DEBUG_AUTO_SYNC
public static final boolean DEBUG_AUTO_SYNC_UID
| Method Detail |
|---|
public static Object initialize()
public static boolean dataStoresPendingActivation()
public static void flattenStores()
throws IOException
IOExceptionpublic static void dumpList()
public static void dumpList(Application app)
app - the application whose data stores should be printed out, or null for all applicationspublic int compareTo(Object o)
compareTo in interface Comparablepublic static void discardAllOnReboot()
public static DataStore createDataStore(String name)
public static DataStore createDataStore(String name,
boolean autoSync)
public static DataStore createSharedDataStore(String name)
public static DataStore createSharedDataStore(String name,
boolean autoSync)
public static void deleteDataStore(DataStore inDS)
public static void deleteLocalDataStore(DataStore inDS)
public static void recoverDataStores()
public static String[] getAllFullNames()
public static DataStore findDataStore(String name)
public static DataStore findSharedDataStore(String name)
public void setVersion(int inVersion)
inVersion - the application-defined version number of this DataStore.public int getVersion()
public static boolean autoSyncToService()
public static void processBackingStoreResponse(BackingStoreTransaction bt)
public int getRecordCount()
public long getLastModifiedMillis()
public int getLastModified()
public long getLastSyncedMillis()
public int getLastSynced()
public String getFullName()
public String getDBName()
public void updateLastModified()
public void updateLastSynced()
public void discardOnReboot(boolean flag)
public boolean discardOnReboot()
public boolean autoSync()
true if this is an autosynced DataStore, false
if it is not.public int getAutoSyncNextUID()
public int addRecord(byte[] data)
public int addRecord(byte[] data,
int flags)
data - The byte array that contains the new record's data.flags - The flags to associate with the new record.
public int addRecord(byte[] data,
int flags,
int uid)
public int insertRecord(byte[] data,
int index)
public int insertRecord(byte[] data,
int index,
int flags)
public void removeRecord(int n)
public void removeRecordWithoutAutoSync(int n)
public void removeRecordByUID(int uid)
removeRecord(int) for this
record. Does nothing if no record with the specified UID exists.
uid - the uid of the record to be removed.public void removeAllRecords()
public byte[][] getRecords()
public byte[] getRecordData(int n)
n - The index of the record whose byte array reference to return.
null if n specifies an invalid index.public int getRecordIndexByUID(int uid)
uid - The uid to search for.
public byte[] getRecordDataByUID(int uid)
uid - The uid to search for.
null if there is no record with that uid.public int getRecordFlags(int n)
n - The index of the record for which to return its flags.
0 there is no record with index n.public boolean isRecordDirty(int n)
n - The index of the record to check.
true is the record with index n has been modified, false if
is has not been modified. Also, false is returned if there is no record with index n.public int getRecordUID(int n)
n - The index of the record for which to return its UID.
0 if n
specifies an invalid index.
public void setRecordData(int n,
byte[] data)
n - The index of the record whose record data to replace.data - The record data that replaces the old record data.
public void setRecordData(int n,
byte[] data,
boolean makeDirty)
setRecordData(int n, byte[] data) instead.
n - The index of the record whose record data to replace.data - The record data that replaces the old record data.makeDirty - true if the record's dirty flag, and the dataStore's
lastModified time should be set, false if not.
public void setRecordDataByUID(int uid,
byte[] data)
uid with the data of the
provided byte array, sets the record's dirty flag, and updates the
DataStore's last modified time. Does nothing if a record with id
uid does not exist.
uid - The id of the record whose record data to replace.data - The record data that replaces the old record data.
public void setRecordDataByUID(int uid,
byte[] data,
boolean makeDirty)
public void setRecordFlags(int n,
int flags)
n - The index of the record whose non-reserved flags to set.flags - The flags to set the record's non-reserved flags to.
public void setRecordFlagsByUID(int uid,
int flags)
uid - The uid of the record whose non-reserved flags to set.flags - The flags to set the record's non-reserved flags to.
public void setRecordDirty(int n,
boolean flag)
n - The index of the record for which to set or clear the flag. This method does nothing if n
specifies an invalid index.flag - true if the flag should be set, false if the flag should be cleared.
public void setRecordUID(int n,
int uid)
public void sort(Comparator comparator)
public void sortByUID()
public int insertRecordSorted(Comparator inComparator,
byte[] inItem)
public int insertRecordSorted(int inUID,
byte[] inItem)
public int binarySearch(int inUID)
public int binarySearch(Comparator inComparator,
byte[] inKey)
public void swapRecords(int this_rec,
int that_rec)
public void autoSyncFromServiceDone()
public void doneResolvingConflict()
public void setAutoSyncNotifyee(Listener inNotifyee)
It is extremely important that if the application registers a listener via setAutoSyncNotifyee(danger.app.Listener),
that listener MUST call doneResolvingConflict(). This is because doneResolvingConflict() has
the side effect of re-enabling that DataStore for autosyncing with the service.
public void setAutoSyncNotifyee(Listener inNotifyee,
Bundle bundle)
public static void allowAutoSyncToService(boolean flag)
public int getByteSize()
public int getBytesUsed()
getByteSize() because the overhead imposed by
the DataStore's internal representation, is not included in this number.
public static void registerListenerForAutoSyncDone(Listener inListener)
public static void deregisterListenerForAutoSyncDone(Listener inListener)
public static void broadcastAutoSyncDone()
public static boolean journalReconcile(Object inKey,
String inName)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||