public interface KvManager
KvStore database,
including obtaining, closing, and deleting the KvStore.SystemCapability.Data#DATA_DISTRIBUTEDDATAMGR| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
closeKvStore(KvStore kvStore) |
Closes the
KvStore database. |
void |
deleteKvStore(String storeId) |
Deletes the
KvStore database identified by storeId. |
List<String> |
getAllKvStoreId() |
Obtains the
storeId of all KvStore databases that are created
by using the getKvStore method and not deleted by calling the deleteKvStore method. |
List<DeviceInfo> |
getConnectedDevicesInfo(DeviceFilterStrategy strategy) |
Get all connected devices information, which has distributed capability.
|
<KVSTORE extends KvStore> |
getKvStore(Options options,
String storeId) |
Creates and obtains a
KvStore database by specifying Options and storeId. |
DeviceInfo |
getLocalDeviceInfo() |
Get local device information;
|
void |
registerDeviceChangeCallback(DeviceChangeCallback callback,
DeviceFilterStrategy strategy) |
register DeviceChangeCallback to get notification when device's status changed
|
void |
unRegisterDeviceChangeCallback(DeviceChangeCallback callback) |
unRegister DeviceChangeCallback and can not receive notification
|
<KVSTORE extends KvStore> KVSTORE getKvStore(Options options, String storeId) throws KvStoreException
KvStore database by specifying Options and storeId.options - Indicates the options used for creating and obtaining the KvStore database,
including isCreateIfMissing, isEncrypt, and KvStoreType.storeId - Identifies the KvStore database.
The value of this parameter must be unique for the same application,
and different applications can share the same value.SingleKvStore, or DeviceKvStore,
as specified by KvStoreType.KvStoreException - Throws this exception if any of the following errors occurs:
IINVALID_ARGUMENT, SERVER_UNAVAILABLE, PERMISSION_DENIED, and IPC_ERROR, DB_ERROR.void closeKvStore(KvStore kvStore) throws KvStoreException
KvStore database. Warning: This method is not thread-safe.
If you call this method to stop a KvStore database that is running, your thread may crash.
The KvStore database to close must be an object created by using the getKvStore method.
Before using this method, release the resources created for the database, for example, KvStoreResultSet
for SingleKvStore,
otherwise closing the database will fail.
If you are attempting to close a database that is already closed, an error will be returned.
kvStore - Indicates the KvStore database to close.KvStoreException - Throws this exception if any of the following errors occurs:
INVALID_ARGUMENT, ERVER_UNAVAILABLE, STORE_NOT_OPEN, STORE_NOT_FOUND, DB_ERROR, PERMISSION_DENIED, and IPC_ERROR.void deleteKvStore(String storeId) throws KvStoreException
KvStore database identified by storeId.
Before using this method, close all KvStore instances in use that are identified
by the same storeId.
You can use this method to delete a KvStore database not in use.
After the database is deleted, all its data will be lost.
storeId - Identifies the KvStore database to delete.KvStoreException - Throws this exception if any of the following errors occurs:
INVALID_ARGUMENT, SERVER_UNAVAILABLE, STORE_NOT_FOUND, DB_ERROR, PERMISSION_DENIED, and IPC_ERROR.List<String> getAllKvStoreId() throws KvStoreException
storeId of all KvStore databases that are created
by using the getKvStore method and not deleted by calling the deleteKvStore method.storeId of all created KvStore databases.KvStoreException - Throws this exception if any of the following errors occurs:
SERVER_UNAVAILABLE, DB_ERROR, PERMISSION_DENIED, and IPC_ERROR.List<DeviceInfo> getConnectedDevicesInfo(DeviceFilterStrategy strategy) throws KvStoreException
strategy - device filter strategy DeviceFilterStrategyKvStoreException - exception maybe occurs.DeviceInfo getLocalDeviceInfo() throws KvStoreException
KvStoreException - exception maybe occurs.void registerDeviceChangeCallback(DeviceChangeCallback callback, DeviceFilterStrategy strategy) throws KvStoreException
callback - device change callback DeviceChangeCallbackstrategy - device filter strategy DeviceFilterStrategyKvStoreException - exception maybe occurs.void unRegisterDeviceChangeCallback(DeviceChangeCallback callback) throws KvStoreException
callback - device change callback DeviceChangeCallback which has been registered.KvStoreException - exception maybe occurs.