de.enough.polish.android.rms
Class SqlDao
java.lang.Object
de.enough.polish.android.rms.SqlDao
public class SqlDao
- extends Object
This DAO manages one database. It is a singleton and is only valid for one application.
TODO: How to close the database? Is there a close hook?
- Author:
- rickyn
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TABLENAME_RECORDSTORE
public static final String TABLENAME_RECORDSTORE
- See Also:
- Constant Field Values
COLUMNNAME_RECORDSTORE_RECORDSTORE_PK
public static final String COLUMNNAME_RECORDSTORE_RECORDSTORE_PK
- See Also:
- Constant Field Values
COLUMNNAME_RECORDSTORE_NAME
public static final String COLUMNNAME_RECORDSTORE_NAME
- See Also:
- Constant Field Values
COLUMNNAME_RECORDSTORE_VERSION
public static final String COLUMNNAME_RECORDSTORE_VERSION
- See Also:
- Constant Field Values
COLUMNNAME_RECORDSTORE_NEXTID
public static final String COLUMNNAME_RECORDSTORE_NEXTID
- See Also:
- Constant Field Values
COLUMNNAME_RECORDSTORE_NUMBER_OF_RECORDS
public static final String COLUMNNAME_RECORDSTORE_NUMBER_OF_RECORDS
- See Also:
- Constant Field Values
COLUMNNAME_RECORDSTORE_SIZE
public static final String COLUMNNAME_RECORDSTORE_SIZE
- See Also:
- Constant Field Values
TABLENAME_RECORD
public static final String TABLENAME_RECORD
- See Also:
- Constant Field Values
COLUMNNAME_RECORD_RECORD_PK
public static final String COLUMNNAME_RECORD_RECORD_PK
- See Also:
- Constant Field Values
COLUMNNAME_RECORD_RECORDSTORE_FK
public static final String COLUMNNAME_RECORD_RECORDSTORE_FK
- See Also:
- Constant Field Values
COLUMNNAME_RECORD_RECORDNUMBER
public static final String COLUMNNAME_RECORD_RECORDNUMBER
- See Also:
- Constant Field Values
COLUMNNAME_RECORD_DATA
public static final String COLUMNNAME_RECORD_DATA
- See Also:
- Constant Field Values
getInstance
public static SqlDao getInstance()
getRecordStore
public RecordStore getRecordStore(String recordStoreName)
- Get the record store with the given name from the database.
- Parameters:
recordStoreName - The name of the record store. Must not be null.
- Returns:
- An RecordStore object or null if the record store could not be found.
getRecordStore
public RecordStore getRecordStore(long pk)
createRecordStore
public RecordStore createRecordStore(String recordStoreName)
throws RecordStoreException
- Creates a record store entry in the database.
- Parameters:
recordStoreName - The name of the record store to be created. The name must be unique. The value must not be null.
- Returns:
- A RecordStore object.
- Throws:
RecordStoreException
DaoException - In case anything goes wrong. This situation is fatal.
destroy
public void destroy()
listRecordStores
public String[] listRecordStores()
deleteRecordStore
public void deleteRecordStore(String recordStoreName)
throws RecordStoreNotFoundException
- Throws:
RecordStoreNotFoundException
addRecord
public int addRecord(long recordStoreFk,
byte[] data)
throws RecordStoreException
- Parameters:
recordStoreFk - the primary key of the recordstore this record is created in. This value must be valid as it is not checked.data - Must not be null.
- Returns:
- the id of the added record
- Throws:
RecordStoreException
getRecord
public byte[] getRecord(long recordStorePk,
int recordId)
throws InvalidRecordIDException
- Parameters:
recordStorePk - recordId -
- Returns:
- the data, or null
- Throws:
InvalidRecordIDException
setRecord
public void setRecord(long recordStorePk,
int recordId,
byte[] data)
throws RecordStoreException
- Parameters:
recordStorePk - recordId - data - Must not be null.
- Throws:
RecordStoreException
removeRecord
public void removeRecord(long recordStorePk,
int recordId)
throws RecordStoreException
- Throws:
RecordStoreException
getRecordIdsForRecordStore
public int[] getRecordIdsForRecordStore(long recordStorePk)
getRecordSize
public int getRecordSize()