source stringlengths 14 113 | code stringlengths 10 21.3k |
|---|---|
application-dev\database\data-persistence-by-graph-store.md | const CREATE_GRAPH = "CREATE GRAPH test " +
"{ (person:Person {name STRING, age INT}),(person)-[:Friend {year INT}]->(person) };"
if(store != null) {
(store as graphStore.GraphStore).write(CREATE_GRAPH).then(() => {
console.info('Create graph successfully');
}).catch((err: BusinessError) => {
... |
application-dev\database\data-persistence-by-graph-store.md | const INSERT_VERTEX_1 = "INSERT (:Person {name: 'name_1', age: 11});";
const INSERT_VERTEX_2 = "INSERT (:Person {name: 'name_2', age: 22});";
const INSERT_VERTEX_3 = "INSERT (:Person {name: 'name_3', age: 0});";
const UPDATE_VERTEX_3 = "MATCH (p:Person) WHERE p.name='name_3' SET p.age=33;"
const INSERT_ED... |
application-dev\database\data-persistence-by-graph-store.md | const QUERY_VERTEX = "MATCH (person:Person) RETURN person;"
const QUERY_EDGE = "MATCH ()-[relation:Friend]->() RETURN relation;"
const QUERY_PATH = "MATCH path=(a:Person {name: 'name_1'})-[]->{2, 2}(b:Person {name: 'name_3'}) RETURN path;"
if(store != null) {
(store as graphStore.GraphStore).read(QUERY... |
application-dev\database\data-persistence-by-graph-store.md | const DELETE_VERTEX_AND_RELATED_EDGE = "MATCH (p:Person {name: 'name_1'}) DETACH DELETE p;"
const DELETE_EDGE_ONLY = "MATCH (p2:Person {name: 'name_2'})-[relation: Friend]->(p3:Person {name: 'name_3'})" +
" DETACH DELETE relation;"
if(store != null) {
(store as graphStore.GraphStore).write(DELETE_VERT... |
application-dev\database\data-persistence-by-graph-store.md | let transactionRead: graphStore.Transaction | null = null;
let transactionWrite: graphStore.Transaction | null = null;
const INSERT = "INSERT (:Person {name: 'name_5', age: 55});";
const QUERY = "MATCH (person:Person) RETURN person;";
if(store != null) {
(store as graphStore.GraphStore).createTra... |
application-dev\database\data-persistence-by-graph-store.md | const DROP_GRAPH_GQL = "DROP GRAPH test;"
class EntryAbility extends UIAbility {
onWindowStageDestroy() {
if(store != null) {
// Delete the graph. This process is skipped here.
(store as graphStore.GraphStore).write(DROP_GRAPH_GQL).then(() => {
console.info('Drop graph suc... |
application-dev\database\data-persistence-by-preferences.md | import { preferences } from '@kit.ArkData'; |
application-dev\database\data-persistence-by-preferences.md | let isGskvSupported = preferences.isStorageTypeSupported(preferences.StorageType.GSKV);
console.info("Is gskv supported on this platform: " + isGskvSupported); |
application-dev\database\data-persistence-by-preferences.md | import { UIAbility } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';
let dataPreferences: preferences.Preferences | null = null;
class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: window.WindowStage) {
let... |
application-dev\database\data-persistence-by-preferences.md | // Obtain the context.
import { featureAbility } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let context = featureAbility.getContext();
let options: preferences.Options = { name: 'myStore' };
let dataPreferences: preferences.Preferences = preferences.getPreferencesSyn... |
application-dev\database\data-persistence-by-preferences.md | import { UIAbility } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';
let dataPreferences: preferences.Preferences | null = null;
class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: window.WindowStage) {
let... |
application-dev\database\data-persistence-by-preferences.md | // Obtain the context.
import { featureAbility } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let context = featureAbility.getContext();
let options: preferences.Options = { name: 'myStore' , storageType: preferences.StorageType.GSKV};
let dataPreferences: preferences.... |
application-dev\database\data-persistence-by-preferences.md | import { util } from '@kit.ArkTS';
if (dataPreferences.hasSync('startup')) {
console.info("The key 'startup' is contained.");
} else {
console.info("The key 'startup' does not contain.");
// Add a KV pair.
dataPreferences.putSync('startup', 'auto');
// If a string contains special charact... |
application-dev\database\data-persistence-by-preferences.md | let val = dataPreferences.getSync('startup', 'default');
console.info("The 'startup' value is " + val);
// If the value is a string containing special characters, it is stored in the Uint8Array format. Convert the obtained Uint8Array into a string.
let uInt8Array2 : preferences.ValueType = dataPreferences.getS... |
application-dev\database\data-persistence-by-preferences.md | dataPreferences.deleteSync('startup'); |
application-dev\database\data-persistence-by-preferences.md | dataPreferences.flush((err: BusinessError) => {
if (err) {
console.error(`Failed to flush. Code:${err.code}, message:${err.message}`);
return;
}
console.info('Succeeded in flushing.');
}) |
application-dev\database\data-persistence-by-preferences.md | let observer = (key: string) => {
console.info('The key' + key + 'changed.');
}
dataPreferences.on('change', observer);
// The data is changed from 'auto' to 'manual'.
dataPreferences.put('startup', 'manual', (err: BusinessError) => {
if (err) {
console.error(`Failed to put the value of 'st... |
application-dev\database\data-persistence-by-preferences.md | let observer = (key: string) => {
console.info('The key' + key + 'changed.');
}
dataPreferences.on('change', observer);
// The data is changed from 'auto' to 'manual'.
dataPreferences.put('startup', 'manual', (err: BusinessError) => {
if (err) {
console.error(`Failed to put the value... |
application-dev\database\data-persistence-by-preferences.md | preferences.deletePreferences(this.context, options, (err: BusinessError) => {
if (err) {
console.error(`Failed to delete preferences. Code:${err.code}, message:${err.message}`);
return;
}
console.info('Succeeded in deleting preferences.');
}) |
application-dev\database\data-persistence-by-rdb-store.md | import { relationalStore} from '@kit.ArkData'; // Import the relationalStore module.
import { UIAbility } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';
// In this example, Ability is used to obtain an RdbStore instance. You can use other... |
application-dev\database\data-persistence-by-rdb-store.md | import { relationalStore} from '@kit.ArkData'; // Import the relationalStore module.
import { featureAbility } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let context = featureAbility.getContext();
const STORE_CONFIG: relationalStore.StoreConfig = {
name: 'RdbTes... |
application-dev\database\data-persistence-by-rdb-store.md | let store: relationalStore.RdbStore | undefined = undefined;
let value1 = 'Lisa';
let value2 = 18;
let value3 = 100.5;
let value4 = new Uint8Array([1, 2, 3, 4, 5]);
let value5 = BigInt('15822401018187971961171');
// You can use either of the following:
const valueBucket1: relationalStore.ValuesBuc... |
application-dev\database\data-persistence-by-rdb-store.md | let value6 = 'Rose';
let value7 = 22;
let value8 = 200.5;
let value9 = new Uint8Array([1, 2, 3, 4, 5]);
let value10 = BigInt('15822401018187971967863');
// You can use either of the following:
const valueBucket4: relationalStore.ValuesBucket = {
'NAME': value6,
'AGE': value7,
'SALARY': ... |
application-dev\database\data-persistence-by-rdb-store.md | let predicates2 = new relationalStore.RdbPredicates('EMPLOYEE');
predicates2.equalTo('NAME', 'Rose');
if (store !== undefined) {
(store as relationalStore.RdbStore).query(predicates2, ['ID', 'NAME', 'AGE', 'SALARY', 'IDENTITY'], (err: BusinessError, resultSet) => {
if (err) {
console.error(`F... |
application-dev\database\data-persistence-by-rdb-store.md | let store: relationalStore.RdbStore | undefined = undefined;
if (store !== undefined) {
// Create an FTS table.
const SQL_CREATE_TABLE = "CREATE VIRTUAL TABLE example USING fts4(name, content, tokenize=icu zh_CN)";
(store as relationalStore.RdbStore).executeSql(SQL_CREATE_TABLE, (err: BusinessError) ... |
application-dev\database\data-persistence-by-rdb-store.md | if (store !== undefined) {
// Backup.db indicates the name of the database backup file. By default, it is in the same directory as the RdbStore file. You can also specify the directory, which is in the customDir + backup.db format.
(store as relationalStore.RdbStore).backup("Backup.db", (err: BusinessError) =... |
application-dev\database\data-persistence-by-rdb-store.md | if (store !== undefined) {
(store as relationalStore.RdbStore).restore("Backup.db", (err: BusinessError) => {
if (err) {
console.error(`Failed to restore RdbStore. Code:${err.code}, message:${err.message}`);
return;
}
console.info(`Succeeded in restoring RdbStore.`);
})
... |
application-dev\database\data-persistence-by-rdb-store.md | relationalStore.deleteRdbStore(this.context, 'RdbTest.db', (err: BusinessError) => {
if (err) {
console.error(`Failed to delete RdbStore. Code:${err.code}, message:${err.message}`);
return;
}
console.info('Succeeded in deleting RdbStore.');
}); |
application-dev\database\data-persistence-by-rdb-store.md | relationalStore.deleteRdbStore(context, 'RdbTest.db', (err: BusinessError) => {
if (err) {
console.error(`Failed to delete RdbStore. Code:${err.code}, message:${err.message}`);
return;
}
console.info('Succeeded in deleting RdbStore.');
}); |
application-dev\database\data-persistence-by-vector-store.md | import { relationalStore } from '@kit.ArkData'; // Import the relationalStore module.
import { UIAbility } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';
// In this example, Ability is used to obtain an RdbStore instance. You can use ... |
application-dev\database\data-persistence-by-vector-store.md | let store: relationalStore.RdbStore | undefined = undefined;
const STORE_CONFIG :relationalStore.StoreConfig= {
name: 'VectorTest.db', // Database file name.
securityLevel: relationalStore.SecurityLevel.S1 // Database security level.
vector: true // Optional. This parameter must be true for a vector s... |
application-dev\database\data-persistence-by-vector-store.md | try {
// Use parameter binding.
const vectorValue: Float32Array = Float32Array.from([1.2, 2.3]);
await store!.execute("insert into test VALUES(?, ?);", 0, [0, vectorValue]);
// Do not use parameter binding.
await store!.execute("insert into test VALUES(1, '[1.3, 2.4]');", 0, undefined);
} ca... |
application-dev\database\data-persistence-by-vector-store.md | // Modify data.
try {
// Use parameter binding.
const vectorValue1: Float32Array = Float32Array.from([2.1, 3.2]);
await store!.execute("update test set repr = ? where id = ?", 0, [vectorValue1, 0]);
// Do not use parameter binding.
await store!.execute("update test set repr = '[5.1, 6.1]' wh... |
application-dev\database\data-persistence-by-vector-store.md | // Perform single-table queries.
try {
// Use parameter binding.
const QUERY_SQL = "select id, repr <-> ? as distance from test where id > ? order by repr <-> ? limit 5;";
const vectorValue2: Float32Array = Float32Array.from([6.2, 7.3]);
let resultSet = await store!.querySql(QUERY_SQL, [vectorVal... |
application-dev\database\data-persistence-by-vector-store.md | // Perform view queries.
try {
// Create a view.
await store!.execute("CREATE VIEW v1 as select * from test where id > 0;");
let resultSet = await store!.querySql("select * from v1;");
resultSet!.close();
} catch (err) {
console.error(`query failed, code is ${err.code}, message is ${err.m... |
application-dev\database\data-persistence-by-vector-store.md | // Basic syntax
try {
// Create an index using the basic syntax. The index name is diskann_l2_idx, index column is repr, type is gsdiskann, and the distance metric is L2.
await store!.execute("CREATE INDEX diskann_l2_idx ON test USING GSDISKANN(repr L2);");
// Delete the diskann_l2_idx index from the ... |
application-dev\database\data-persistence-by-vector-store.md | try {
// The write operation performed every 5 minutes will trigger a data aging task.
await store!.execute("CREATE TABLE test2(rec_time integer not null) WITH (time_col = 'rec_time', interval = '5 minute');");
} catch (err) {
console.error(`configure data aging failed, code is ${err.code}, message is... |
application-dev\database\data-persistence-by-vector-store.md | try {
await relationalStore.deleteRdbStore(this.context, STORE_CONFIG);
} catch (err) {
console.error(`delete rdbStore failed, code is ${err.code},message is ${err.message}`);
} |
application-dev\database\data-sync-of-distributed-data-object.md | dataObject['parents'] = {mom: "amy"}; // Supported modification
dataObject['parents']['mon'] = "amy"; // Unsupported modification |
application-dev\database\data-sync-of-distributed-data-object.md | import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
import { commonType, distributedDataObject } from '@kit.ArkData';
import { fileIo, fileUri } from '@kit.CoreFileKit';
import { BusinessError } from '@kit.BasicSer... |
application-dev\database\data-sync-of-distributed-data-object.md | import { AbilityConstant, Caller, common, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
import { distributedDataObject } from '@kit.ArkData';
import { distributedDeviceManager } from '@kit.DistributedServiceKit';
import { BusinessErro... |
application-dev\database\data-sync-of-kv-store.md | import { distributedKVStore } from '@kit.ArkData'; |
application-dev\database\data-sync-of-kv-store.md | // Obtain the context of the stage model.
import { window } from '@kit.ArkUI';
import { UIAbility } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
let kvManager: distributedKVStore.KVManager | undefined = undefined;
class EntryAbility extends UIAbility {
onWin... |
application-dev\database\data-sync-of-kv-store.md | let kvStore: distributedKVStore.SingleKVStore | undefined = undefined;
try {
let child1 = new distributedKVStore.FieldNode('id');
child1.type = distributedKVStore.ValueType.INTEGER;
child1.nullable = false;
child1.default = '1';
let child2 = new distributedKVStore.FieldNode('name');
chi... |
application-dev\database\data-sync-of-kv-store.md | try {
kvStore.on('dataChange', distributedKVStore.SubscribeType.SUBSCRIBE_TYPE_ALL, (data) => {
console.info(`dataChange callback call data: ${data}`);
});
} catch (e) {
let error = e as BusinessError;
console.error(`An unexpected error occurred. code:${error.code},message:${error.message}... |
application-dev\database\data-sync-of-kv-store.md | const KEY_TEST_STRING_ELEMENT = 'key_test_string';
// If schema is not defined, pass in other values that meet the requirements.
const VALUE_TEST_STRING_ELEMENT = '{"id":0, "name":"lisi"}';
try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, (err) => {
if (err !== undefined) {
... |
application-dev\database\data-sync-of-kv-store.md | try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, (err) => {
if (err !== undefined) {
console.error(`Failed to put data. Code:${err.code},message:${err.message}`);
return;
}
console.info('Succeeded in putting data.');
kvStore = kvStore as distribute... |
application-dev\database\data-sync-of-kv-store.md | import { distributedDeviceManager } from '@kit.DistributedServiceKit';
let devManager: distributedDeviceManager.DeviceManager;
try {
// create deviceManager
devManager = distributedDeviceManager.createDeviceManager(context.applicationInfo.name);
// deviceIds is obtained by devManager.getAvaila... |
application-dev\database\data-sync-of-rdb-store.md | import { relationalStore } from '@kit.ArkData'; |
application-dev\database\data-sync-of-rdb-store.md | import { UIAbility } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';
class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: window.WindowStage) {
const STORE_CONFIG: relationalStore.StoreConfig = {
name: ... |
application-dev\database\data-sync-of-rdb-store.md | // Construct the predicate object for synchronizing the distributed table.
let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
// Call sync() to synchronize data.
if(store != undefined)
{
(store as relationalStore.RdbStore).sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, (err, res... |
application-dev\database\data-sync-of-rdb-store.md | let devices: string | undefined = undefined;
try {
// Register an observer to listen for the changes of the distributed data.
// When data in the RDB store changes, the registered callback will be invoked to return the data changes.
if(store != undefined) {
(store as relationalStore.RdbStore).o... |
application-dev\database\data-sync-of-rdb-store.md | // Obtain device IDs.
import { distributedDeviceManager } from '@kit.DistributedServiceKit';
import { BusinessError } from '@kit.BasicServicesKit';
let dmInstance: distributedDeviceManager.DeviceManager;
let deviceId: string | undefined = undefined ;
try {
dmInstance = distributedDeviceManager.cre... |
application-dev\database\encrypted_estore_guidelines.md | // module.json5
"requestPermissions": [
{
"name": "ohos.permission.PROTECT_SCREEN_LOCK_DATA"
}
] |
application-dev\database\encrypted_estore_guidelines.md | // Mover.ts
import { distributedKVStore } from '@kit.ArkData';
export class Mover {
async move(eStore: distributedKVStore.SingleKVStore, cStore: distributedKVStore.SingleKVStore): Promise<void> {
if (eStore != null && cStore != null) {
let entries: distributedKVStore.Entry[] = await cStore.getEntries('key_... |
application-dev\database\encrypted_estore_guidelines.md | // Store.ts
import { distributedKVStore } from '@kit.ArkData';
import { BusinessError } from '@kit.BasicServicesKit';
let kvManager: distributedKVStore.KVManager;
export class StoreInfo {
kvManagerConfig: distributedKVStore.KVManagerConfig;
storeId: string;
option: distributedKVStore.Options;
}
export class St... |
application-dev\database\encrypted_estore_guidelines.md | // SecretKeyObserver.ts
import { ECStoreManager } from './ECStoreManager';
export enum SecretStatus {
Lock,
UnLock
}
export class SecretKeyObserver {
onLock(): void {
this.lockStatuas = SecretStatus.Lock;
this.storeManager.closeEStore();
}
onUnLock(): void {
this.lockStatuas = SecretStatus.UnLo... |
application-dev\database\encrypted_estore_guidelines.md | // ECStoreManager.ts
import { distributedKVStore } from '@kit.ArkData';
import { Mover } from './Mover';
import { BusinessError } from '@kit.BasicServicesKit';
import { StoreInfo, Store } from './Store';
import { SecretStatus } from './SecretKeyObserver';
let store = new Store();
export class ECStoreManager {
confi... |
application-dev\database\encrypted_estore_guidelines.md | // EntryAbility.ets
import { AbilityConstant, application, contextConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
import { distributedKVStore } from '@kit.ArkData';
import { ECStoreManager } from './ECStoreManager';
import { S... |
application-dev\database\encrypted_estore_guidelines.md | // Index.ets
import { storeManager, e_secretKeyObserver } from "../entryability/EntryAbility";
import { distributedKVStore } from '@kit.ArkData';
import { Store } from '../entryability/Store';
let storeOption = new Store();
let lockStatus: number = 1;
@Entry
@Component
struct Index {
@State message: string = 'Hell... |
application-dev\database\encrypted_estore_guidelines.md | // Mover.ts
import { relationalStore } from '@kit.ArkData';
export class Mover {
async move(eStore: relationalStore.RdbStore, cStore: relationalStore.RdbStore) {
if (eStore != null && cStore != null) {
let predicates = new relationalStore.RdbPredicates('employee');
let resultSet = await cStore.query(... |
application-dev\database\encrypted_estore_guidelines.md | // Store.ts
import { relationalStore } from '@kit.ArkData';
import { BusinessError } from '@kit.BasicServicesKit';
import { Context } from '@kit.AbilityKit';
export class StoreInfo {
context: Context;
config: relationalStore.StoreConfig;
storeId: string;
}
let id = 1;
const SQL_CREATE_TABLE = 'CREATE TABLE IF N... |
application-dev\database\encrypted_estore_guidelines.md | // SecretKeyObserver.ts
import { ECStoreManager } from './ECStoreManager';
export enum SecretStatus {
Lock,
UnLock
}
export class SecretKeyObserver {
onLock(): void {
this.lockStatuas = SecretStatus.Lock;
this.storeManager.closeEStore();
}
onUnLock(): void {
this.lockStatuas = SecretStatus.UnLo... |
application-dev\database\encrypted_estore_guidelines.md | // ECStoreManager.ts
import { relationalStore } from '@kit.ArkData';
import { Mover } from './Mover';
import { BusinessError } from '@kit.BasicServicesKit';
import { StoreInfo, Store } from './Store';
import { SecretStatus } from './SecretKeyObserver';
let store = new Store();
export class ECStoreManager {
config(c... |
application-dev\database\encrypted_estore_guidelines.md | // EntryAbility.ets
import { AbilityConstant, contextConstant, UIAbility, Want, application } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
import { relationalStore } from '@kit.ArkData';
import { ECStoreManager } from './ECStoreManager';
import { Stor... |
application-dev\database\encrypted_estore_guidelines.md | // Index.ets
import { storeManager, e_secretKeyObserver } from "../entryability/EntryAbility";
import { relationalStore } from '@kit.ArkData';
import { Store } from '../entryability/Store';
let storeOption = new Store();
let lockStatus: number = 1;
@Entry
@Component
struct Index {
@State message: string = 'Hello W... |
application-dev\database\share-data-by-datashareextensionability.md | import { DataShareExtensionAbility, dataShare, dataSharePredicates, relationalStore, DataShareResultSet } from '@kit.ArkData';
import { Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit' |
application-dev\database\share-data-by-datashareextensionability.md | const DB_NAME = 'DB00.db';
const TBL_NAME = 'TBL00';
const DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+ TBL_NAME
+ ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, isStudent BOOLEAN, Binary BINARY)';
let rdbStore: relationalStore.RdbStore;
let result: string;
export defaul... |
application-dev\database\share-data-by-datashareextensionability.md | import { UIAbility } from '@kit.AbilityKit';
import { dataShare, dataSharePredicates, DataShareResultSet, ValuesBucket } from '@kit.ArkData';
import { window } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit'; |
application-dev\database\share-data-by-datashareextensionability.md | // Different from the URI defined in the module.json5 file, the URI passed in the parameter has an extra slash (/), because there is a DeviceID parameter between the second and the third slash (/).
let dseUri = ('datashare:///com.ohos.settingsdata.DataAbility'); |
application-dev\database\share-data-by-datashareextensionability.md | let dsHelper: dataShare.DataShareHelper | undefined = undefined;
let abilityContext: Context;
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: window.WindowStage) {
abilityContext = this.context;
dataShare.createDataShareHelper(abilityContext, dseUri, (err... |
application-dev\database\share-data-by-datashareextensionability.md | // Construct a piece of data.
let key1 = 'name';
let key2 = 'age';
let key3 = 'isStudent';
let key4 = 'Binary';
let valueName1 = 'ZhangSan';
let valueName2 = 'LiSi';
let valueAge1 = 21;
let valueAge2 = 18;
let valueIsStudent1 = false;
let valueIsStudent2 = true;
let valueBinary = new Ui... |
application-dev\database\share-data-by-silent-access.md | import { dataShare, dataSharePredicates, ValuesBucket } from '@kit.ArkData';
import { UIAbility } from '@kit.AbilityKit';
import { window } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit' |
application-dev\database\share-data-by-silent-access.md | let dseUri = ('datashareproxy://com.ohos.settingsdata/entry/settingsdata/USER_SETTINGSDATA_SECURE'); |
application-dev\database\share-data-by-silent-access.md | let dsHelper: dataShare.DataShareHelper | undefined = undefined;
let abilityContext: Context;
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: window.WindowStage) {
abilityContext = this.context;
dataShare.createDataShareHelper(abilityContext, dseUri, {
... |
application-dev\database\share-data-by-silent-access.md | // Construct a piece of data.
let key1 = 'name';
let key2 = 'age';
let key3 = 'isStudent';
let key4 = 'Binary';
let valueName1 = 'ZhangSan';
let valueName2 = 'LiSi';
let valueAge1 = 21;
let valueAge2 = 18;
let valueIsStudent1 = false;
let valueIsStudent2 = true;
let valueBinary = new Ui... |
application-dev\database\share-data-by-silent-access.md | function onCallback(err: BusinessError, node: dataShare.RdbDataChangeNode) {
console.info("uri " + JSON.stringify(node.uri));
console.info("templateId " + JSON.stringify(node.templateId));
console.info("data length " + node.data.length);
for (let i = 0; i < node.data.length; i++) {
console.in... |
application-dev\database\share-data-by-silent-access.md | import { dataShare } from '@kit.ArkData';
import { UIAbility } from '@kit.AbilityKit';
import { window } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit'; |
application-dev\database\share-data-by-silent-access.md | let dseUri = ('datashareproxy://com.acts.ohos.data.datasharetest/weather'); |
application-dev\database\share-data-by-silent-access.md | let dsHelper: dataShare.DataShareHelper | undefined = undefined;
let abilityContext: Context;
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: window.WindowStage) {
abilityContext = this.context;
dataShare.createDataShareHelper(abilityContext, dseUri, {isP... |
application-dev\database\share-data-by-silent-access.md | // Construct two pieces of data. The first data is not configured with proxyDatas and cannot be accessed by other applications.
let data : Array<dataShare.PublishedItem> = [
{key:"city", subscriberId:"11", data:"xian"},
{key:"datashareproxy://com.acts.ohos.data.datasharetest/weather", subscriberId:"11", da... |
application-dev\database\share-data-by-silent-access.md | function onPublishCallback(err: BusinessError, node:dataShare.PublishedDataChangeNode) {
console.info("onPublishCallback");
}
let uris:Array<string> = ["city", "datashareproxy://com.acts.ohos.data.datasharetest/weather"];
if (dsHelper != undefined) {
let result: Array<dataShare.OperationResult> = (ds... |
application-dev\database\share-data-by-silent-access.md | import { dataShare } from '@kit.ArkData';
import { UIAbility } from '@kit.AbilityKit';
import { window } from '@kit.ArkUI'; |
application-dev\database\share-data-by-silent-access.md | let dseUri = ('datashareproxy:///com.ohos.settingsdata/entry/DB00/TBL00'); |
application-dev\database\share-data-by-silent-access.md | let abilityContext: Context;
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: window.WindowStage) {
abilityContext = this.context;
dataShare.enableSilentProxy(abilityContext, dseUri);
}
} |
application-dev\database\unified-data-channels.md | import { unifiedDataChannel, uniformTypeDescriptor, uniformDataStruct } from '@kit.ArkData'; |
application-dev\database\unified-data-channels.md | import { BusinessError } from '@kit.BasicServicesKit';
import { image } from '@kit.ImageKit';
// Create plaintext data.
let plainTextObj : uniformDataStruct.PlainText = {
uniformDataType: 'general.plain-text',
textContent : 'Hello world',
abstract : 'This is abstract',
}
let record = new u... |
application-dev\database\unified-data-channels.md | let plainTextUpdate : uniformDataStruct.PlainText = {
uniformDataType: 'general.plain-text',
textContent : 'How are you',
abstract : 'This is abstract',
}
let recordUpdate = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.PLAIN_TEXT, plainTextUpdate);
let htmlUpdate : ... |
application-dev\database\unified-data-channels.md | // Specify the type of the data channel whose data is to be deleted.
let optionsDelete: unifiedDataChannel.Options = {
intention: unifiedDataChannel.Intention.DATA_HUB
};
try {
unifiedDataChannel.deleteData(optionsDelete, (err, data) => {
if (err === undefined) {
console.info(`Succee... |
application-dev\database\unified-data-channels.md | import { unifiedDataChannel, uniformTypeDescriptor, uniformDataStruct } from '@kit.ArkData'; |
application-dev\database\unified-data-channels.md | import { BusinessError } from '@kit.BasicServicesKit';
// Specify the type of the data channel whose data is to be queried.
let options: unifiedDataChannel.Options = {
intention: unifiedDataChannel.Intention.DATA_HUB
};
try {
unifiedDataChannel.queryData(options, (err, data) => {
if (err =... |
application-dev\database\uniform-data-structure.md | // 1. Import the unifiedDataChannel and uniformTypeDescriptor modules.
import { uniformDataStruct, uniformTypeDescriptor, unifiedDataChannel } from '@kit.ArkData';
// 2. Create a data record for a hyperlink.
let hyperlinkDetails : Record<string, string> = {
'attr1': 'value1',
'attr2': 'value2',
}
l... |
application-dev\database\uniform-data-type-descriptors.md | // 1. Import the module.
import { uniformTypeDescriptor } from '@kit.ArkData';
try {
// 2. Obtain the UTD type ID (typeId) based on the file name extension .mp3, and then obtain properties of the UTD.
let fileExtention = '.mp3';
let typeId1 = uniformTypeDescriptor.getUniformDataTypeByFilenameExtension(fileExtent... |
application-dev\database\uniform-data-type-descriptors.md | // 1. Import the module.
import { uniformTypeDescriptor } from '@kit.ArkData';
try {
// 2. Obtain the UTD type ID based on the file name extension .ts.
let fileExtention = '.ts';
let typeIds = uniformTypeDescriptor.getUniformDataTypesByFilenameExtension(fileExtention);
for (let typeId of typeIds) {
// 3. Ob... |
application-dev\database\uniform-data-type-descriptors.md | // 1. Import the module.
import { uniformTypeDescriptor } from '@kit.ArkData';
try {
// 2. Obtain the UTD type ID based on the MIME type text/plain.
let mineType = 'text/plain';
let typeIds = uniformTypeDescriptor.getUniformDataTypesByMIMEType(mineType);
for (let typeId of typeIds) {
// 3. Obtain the MIME t... |
application-dev\device\driver\driverextensionability.md | import { DriverExtensionAbility } from '@kit.DriverDevelopmentKit';
import { Want } from '@kit.AbilityKit';
import { rpc } from '@kit.IPCKit';
const REQUEST_CODE = 99; // Negotiate the request code with the peripheral client. |
application-dev\device\driver\driverextensionability.md | class StubTest extends rpc.RemoteObject {
// Receive a message from the application and return the processing result to the client.
onRemoteMessageRequest(code: number, data: rpc.MessageSequence, reply: rpc.MessageSequence,
option: rpc.MessageOption) {
if (code === REQUEST_CODE) {
... |
application-dev\device\driver\driverextensionability.md | export default class DriverExtAbility extends DriverExtensionAbility {
onInit(want: Want) {
console.info('testTag', `onInit, want: ${want.abilityName}`);
}
onRelease() {
console.info('testTag', `onRelease`);
}
onConnect(want: Want) {
console.info('testTag', `onCon... |
application-dev\device\driver\externaldevice-guidelines.md | import { hilog } from '@kit.PerformanceAnalysisKit';
import { deviceManager } from '@kit.DriverDevelopmentKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { rpc } from '@kit.IPCKit';
const REQUEST_CODE: number = 99; // Custom communication code, which is for reference only.
const... |
application-dev\device\driver\externaldevice-guidelines.md | @State message: string = 'Hello';
private remote: rpc.IRemoteObject | null = null; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.