harmony(鸿蒙)DataUriUtils

2022-08-09 浏览 (898)

DataUriUtils

The DataUriUtils module provides APIs to handle utility classes for objects using the DataAbilityHelper schema. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI.

NOTE

The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import dataUriUtils from '@ohos.ability.dataUriUtils';

dataUriUtils.getId

getId(uri: string): number

Obtains the ID attached to the end of a given URI.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Parameters

NameTypeMandatoryDescription
uristringYesURI object from which the ID is to be obtained.

Return value

TypeDescription
numberID obtained from the URI object.

Example

dataUriUtils.getId("com.example.dataUriUtils/1221")

dataUriUtils.attachId

attachId(uri: string, id: number): string

Attaches an ID to the end of a given URI.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Parameters

NameTypeMandatoryDescription
uristringYesURI object to which an ID is to be attached.
idnumberYesID to be attached.

Return value

TypeDescription
stringURI object with the ID attached.

Example

var idint = 1122;
dataUriUtils.attachId(
    "com.example.dataUriUtils",
	idint,
)

dataUriUtils.deleteId

deleteId(uri: string): string

Deletes the ID from the end of a given URI.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Parameters

NameTypeMandatoryDescription
uristringYesURI object from which the ID is to be deleted.

Return value

TypeDescription
stringURI object with the ID deleted.

Example

dataUriUtils.deleteId("com.example.dataUriUtils/1221")

dataUriUtils.updateId

updateId(uri: string, id: number): string

Updates the ID in a given URI.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Parameters

NameTypeMandatoryDescription
uristringYesURI object to be updated.
idnumberYesNew ID.

Return value

TypeDescription
stringURI object with the new ID.

Example

var idint = 1122;
dataUriUtils.updateId(
    "com.example.dataUriUtils",
	idint
)

你可能感兴趣的鸿蒙文章

harmony(鸿蒙)APIs

harmony(鸿蒙)API Reference Document Description

harmony(鸿蒙)BundleStatusCallback

harmony(鸿蒙)innerBundleManager(deprecated)

harmony(鸿蒙)distributedBundle

harmony(鸿蒙)Bundle

harmony(鸿蒙)Context

harmony(鸿蒙)EnterpriseAdminExtensionAbility

harmony(鸿蒙)Work Scheduler Callbacks

harmony(鸿蒙)Ability

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/db5f7ef227834bfba677b2db86ba3863