鸿蒙OS开发文档 第4页

鸿蒙OS SharedResultSet

SharedResultSet public interface SharedResultSet extends ResultSet 提供访问通过跨进程查询数据库获得的数据库结果集的方法。 此类扩展了 ResultSet 类。 该类中的一些方法由抽象类 AbsSharedResultSet 实现。 Since: 3 嵌套类摘要 从接口 ohos.data.resultset.ResultSet 继承的嵌套类/接口 ResultSet.ColumnType 方法总结 修饰符和类型 方法 描述 void fillBlock(int startRowIndex, SharedBlock block) 将 SharedResultSet 的数据添加到 SharedBlock。 SharedBlock getBlock() 从 SharedResultSet 中获取一个块。 boolean onGo(int oldRowIndex, int newRowIndex) 当结果集的位置发生变化时调用。 从接口 ohos.data.resultset.ResultSet 继承的方法 close, getAffectedByUris, getAllColumnNames, getBlob, getColumnCount, getColumnIndexForName, getColumnNameForIndex, getColumnTypeForIndex, getDouble, getExtensions, getFloat, getInt, getLong, getRowCount, getRowIndex, getShort, getString, goTo, goToFirstRow, goToLastRow, goToNextRow, goToPreviousRow, goToRow, isAtFirstRow, isAtLastRow, isClosed, isColumnNull, isEnded, isStarted, registerObserver, setAffectedByUris, setExtensions, unregisterObserver 方法详情 getBlock SharedBlock getBlock() 从 SharedResultSet 中获取一个块。 该块包含 SharedResultSet 的一些数据。 返回: 如果找到,则返回该块; 否则返回 null。 Since: 3 fillBlock void fillBlock(int startRowIndex, SharedBlock block) 将 SharedResultSet 的数据添加到 SharedBlock。 该方法用于将 SharedResultSet 的数据(从 startRowIndex 位置开始)添加到 SharedBlock 中,直到 SharedResultSet 的所有数据都添加到 SharedBlock 或 SharedBlock 空间不足。 参数: 参数名称 参数描述 startRowIndex 表示 SharedResultSet 中的索引。 索引从 0 开始,表示第一行。 block 表示要将其数据添加到 SharedResultSet 的块。 Since: 3 onGo boolean onGo(int oldRowIndex, int newRowIndex) 当结果集的位置发生变化时调用。 当结果集移动到新位置时,调用该方法通知子类移动结果。 如果返回 false,则结果集将移动到 beforeFirst 位置。 参数: 参数名称 参数描述 oldRowIndex 表示结果集的原始位置。 newRowIndex 指示结果集的新位置。 返回: 如果结果集移动成功,则返回 true; 否则返回 false。 Since: 3

鸿蒙OS ResultSetHook

ResultSetHook public interface ResultSetHook 提供创建结果集的方法。 此类允许您自定义结果集。 Since: 1 方法总结 修饰符和类型 方法 描述 void createHook(String sql, String[] sqlArgs, ResultSet resultSet) 创建一个挂钩以自定义指定的结果集。 方法详情 createHook void createHook(String sql, String[] sqlArgs, ResultSet resultSet) 创建一个挂钩以自定义指定的结果集。 参数: 参数名称 参数描述 sql 表示用于自定义结果集的 SQL 语句。 sqlArgs 表示SQL语句中的参数。 这些参数的值是字符串。 resultSet 指示要自定义的结果集。 Since: 1

鸿蒙OS ResultSet

ResultSet public interface ResultSet 提供用于访问通过查询数据库生成的数据库结果集的方法。 抽象类 AbsResultSet 实现了 ResultSet 接口中的一些方法。 Since: 1 嵌套类摘要 修饰符和类型 接口 描述 static class ResultSet.ColumnType 定义结果集中列的数据类型。 方法总结 修饰符和类型 方法 描述 void close() 关闭结果集。 ListUri getAffectedByUris() 获取注册的 URI 列表以观察影响结果集的更改。 String[] getAllColumnNames() 获取结果集中所有列的名称。 byte[] getBlob(int columnIndex) 以字节数组的形式获取当前行中指定列的值。 int getColumnCount() 获取结果集中的列数。 int getColumnIndexForName(String columnName) 根据指定的列名获取列索引。 String getColumnNameForIndex(int columnIndex) 根据指定的列索引获取列名。 ResultSet.ColumnType getColumnTypeForIndex(int columnIndex) 根据指定的列索引获取数据类型。 double getDouble(int columnIndex) 以 double 形式获取当前行中指定列的值。 PacMap getExtensions() 获取结果集的扩展。 float getFloat(int columnIndex) 获取当前行中指定列的值作为浮点数。 int getInt(int columnIndex) 以 int 形式获取当前行中指定列的值。 long getLong(int columnIndex) 以long形式获取当前行中指定列的值。 int getRowCount() 获取结果集中的行数。 int getRowIndex() 获取结果集的当前索引。 short getShort(int columnIndex) 以short形式获取当前行中指定列的值。 String getString(int columnIndex) 以字符串形式获取当前行中指定列的值。 boolean goTo(int offset) 以相对于其当前位置的偏移量向前或向后转到结果集的指定行。 boolean goToFirstRow() 转到结果集的第一行。 boolean goToLastRow() 转到结果集的最后一行。 boolean goToNextRow() 转到结果集的下一行。 boolean goToPreviousRow() 转到结果集的上一行。 boolean goToRow(int rowIndex) 转到结果集的指定行。 boolean isAtFirstRow() 检查结果集是否位于第一行。 boolean isAtLastRow() 检查结果集是否位于最后一行。 boolean isClosed() 检查当前结果集是否关闭。 boolean isColumnNull(int columnIndex) 检查当前行中指定列的值是否为空。 boolean isEnded() 检查结果集是否位于最后一行之后。 boolean isStarted() 检查结果集是否已移动。 void registerObserver(DataObserver observer) 注册一个监听数据变化的观察者。 void setAffectedByUris(Object context, ListUri uris) 设置要观察的数据的 URI。 void setExtensions(PacMap extensions) 设置结果集的扩展。 void...

鸿蒙OS ResourceManager

ResourceManager java.lang.Object |—ohos.global.resource.ResourceManager public abstract class ResourceManager extends Object 管理应用程序包资源目录下的所有资源。 ResourceManager 实例仅从上下文中获取。 Since: 1 构造函数摘要 构造函数 描述 ResourceManager() 方法总结 修饰符和类型 方法 描述 abstract Pattern createPattern(ListTypedAttribute.AttrData data) 基于包含 TypedAttribute.AttrData 的数组创建 Pattern 实例。 abstract Theme createTheme(ListTypedAttribute.AttrData data) 基于包含 TypedAttribute.AttrData 的数组创建一个 Theme 实例。 abstract ConfigManager getConfigManager() 获取 ConfigManager 以获取全局配置。 abstract Configuration getConfiguration() 获取当前配置。 abstract DeviceCapability getDeviceCapability() 获取设备能力。 abstract Element getElement(int resId) 根据资源 ID 获取 Element 对象。 abstract String getIdentifier(int resId) 根据资源ID获取资源名称。 abstract String getMediaPath(int resId) 根据资源ID获取媒体文件路径。 abstract RawFileEntry getRawFileEntry(String path) 根据原始文件路径获取 RawFileEntry 对象以打开原始文件。 abstract Resource getResource(int resId) 根据资源ID获取资源。 abstract SolidXml getSolidXml(int resId) 根据资源 ID 获取一个可靠的 XML 文档。 abstract Theme getTheme(int resId) 已弃用。 此更改从 API 版本 4 开始生效。由 Element#getTheme() 替换 abstract void updateConfiguration(Configuration config, DeviceCapability capability) 通过修改配置和设备能力来更新配置。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 构造函数详细信息 ResourceManager public ResourceManager() 方法详情 getResource public abstract Resource getResource(int resId) throws IOException, NotExistException 根据资源ID获取资源。 参数: 参数名称 参数描述 resId 表示资源ID。 返回: 返回资源对象; 如果资源 ID 不匹配任何资源,则返回 null。 Throws: Throw名称 Throw描述 NotExistException 如果资源 ID 与任何资源都不匹配,则引发此异常。 资源ID必须由IDE或资源工具自动生成,或者由系统提供。 IOException 如果在资源读取期间发生 I/O 错误,则引发此异常。 getIdentifier public abstract String getIdentifier(int resId) throws IOException, NotExistException 根据资源ID获取资源名称。 参数: 参数名称 参数描述 resId 表示资源ID。 返回: 返回类型为 type_name 的资源名称; 如果资源 ID 不匹配任何资源,则返回...

鸿蒙OS Resource

Resource java.lang.Object |—java.io.InputStream |—|—ohos.global.resource.Resource public abstract class Resource extends InputStream 描述可以从中读取资源数据的输入流。 资源实例只能使用 ResourceManager.getResource(int) 方法获取。 Since: 1 构造函数摘要 构造函数 描述 Resource() 方法总结 修饰符和类型 方法 描述 abstract int available() 获取可以从资源中读取的总字节数。 abstract void close() 关闭此资源并释放与流关联的所有系统资源。 int read() 从资源中读取下一个字节。 abstract int read(byte[] bytes, int off, int len) 从资源中读取最多 len 个字节。 从类 java.io.InputStream 继承的方法 mark, markSupported, read, reset, skip 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 构造函数详细信息 Resource public Resource() 方法详情 available public abstract int available() throws IOException 获取可以从资源中读取的总字节数。 覆盖: 在类 InputStream 中可用 返回: 返回可以从资源中读取的总字节数。 Throws: Throw名称 Throw描述 IOException 如果发生 I/O 错误,则引发此异常。 read public abstract int read(byte[] bytes, int off, int len) throws IOException, IndexOutOfBoundsException, NullPointerException 从资源中读取最多 len 个字节。 覆盖: 读入类 InputStream 参数: 参数名称 参数描述 bytes 指示读取数据的缓冲区。 off 指示写入数据的数组字节的起始偏移量。 len 指示要读取的最大字节数。 返回: 返回读入缓冲区的总字节数; 如果由于到达流的末尾而没有更多数据,则返回 -1。 Throws: Throw名称 Throw描述 IOException 如果发生 I/O 错误,则引发此异常。 NullPointerException 如果数组字节为空,则引发此异常。 IndexOutOfBoundsException 如果 off 为负数、len 为负数或 len 大于 bytes.length – off,则抛出此异常。 read public int read() throws IOException 从资源中读取下一个字节。 指定者: 读入类 InputStream...

鸿蒙OS RawFileEntry

RawFileEntry java.lang.Object |—ohos.global.resource.RawFileEntry public abstract class RawFileEntry extends Object 管理应用程序包中的原始文件。 可以从这个类中获取资源。 RawFileEntry 实例只能通过 ResourceManager.getRawFileEntry(String) 方法获取。 Since: 3 构造函数摘要 构造函数 描述 RawFileEntry() 方法总结 修饰符和类型 方法 描述 abstract Entry[] getEntries() 搜索所有原始文件的路径。 abstract Entry.Type getType() 获取 RawFileEntry 的类型,FOLDER 或 FILE。 abstract Resource openRawFile() 获得对原始文件的访问权限。 abstract RawFileDescriptor openRawFileDescriptor() 访问应用程序包中原始文件目录的相对路径中的原始文件的文件描述符。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 构造函数详细信息 RawFileEntry public RawFileEntry() 方法详情 openRawFile public abstract Resource openRawFile() throws IOException 获得对原始文件的访问权限。 返回: 返回原始文件。 Throws: Throw名称 Throw描述 IOException 如果在搜索所有原始文件期间发生 I/O 错误,则引发此异常。 openRawFileDescriptor public abstract RawFileDescriptor openRawFileDescriptor() throws IOException 访问应用程序包中原始文件目录的相对路径中的原始文件的文件描述符。 返回: 返回原始文件的文件描述符。 Throws: Throw名称 Throw描述 IOException 如果在搜索所有原始文件期间发生 I/O 错误,则引发此异常。 getEntries public abstract Entry[] getEntries() throws IOException 搜索所有原始文件的路径。 返回: 返回所有原始文件的路径。 Throws: Throw名称 Throw描述 IOException 如果在搜索所有原始文件期间发生 I/O 错误,则引发此异常。 getType public abstract Entry.Type getType() 获取 RawFileEntry 的类型,FOLDER 或 FILE。 返回: 返回 RawFileEntry 的类型。

鸿蒙OS RawFileDescriptor

RawFileDescriptor java.lang.Object |—ohos.global.resource.BaseFileDescriptor |—|—ohos.global.resource.RawFileDescriptor public abstract class RawFileDescriptor extends BaseFileDescriptor 提供来自 RawFileEntry 的原始文件的文件描述符。 可以使用文件描述符读取数据,获取数据起始位置,获取原始文件的长度。 此类继承自 BaseFileDescriptor。 RawFileDescriptor 实例只能通过 RawFileEntry.openRawFileDescriptor() 方法获取。 Since: 3 构造函数摘要 构造函数 描述 RawFileDescriptor() 方法总结 修饰符和类型 方法 描述 abstract FileDescriptor getFileDescriptor() 获取原始文件的文件描述符。 abstract long getFileSize() 获取原始文件的大小。 abstract long getStartPosition() 获取原始文件中数据的起始位置。 从接口 java.io.Closeable 继承的方法 close 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 构造函数详细信息 RawFileDescriptor public RawFileDescriptor() 方法详情 getFileDescriptor public abstract FileDescriptor getFileDescriptor() 获取原始文件的文件描述符。 您可以使用文件描述符来读取原始文件中的数据。 指定者: 类 BaseFileDescriptor 中的 getFileDescriptor 返回: 返回文件描述符。 Since: 3 getFileSize public abstract long getFileSize() 获取原始文件的大小。 指定者: 类 BaseFileDescriptor 中的 getFileSize 返回: 返回原始文件大小,以字节为单位。 Since: 3 getStartPosition public abstract long getStartPosition() 获取原始文件中数据的起始位置。 指定者: 类 BaseFileDescriptor 中的 getStartPosition 返回: 返回起始位置。 Since: 3

鸿蒙OS Entry

Entry java.lang.Object |—ohos.global.resource.Entry public abstract class Entry extends Object 描述 rawfile 目录中的条目。 Since: 3 嵌套类摘要 修饰符和类型 类 描述 static class Entry.Type 表示条目类型。 构造函数摘要 构造函数 描述 Entry() 方法总结 修饰符和类型 方法 描述 abstract String getPath() 获取Entry的路径。 abstract Entry.Type getType() 获取Entry的类型。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 构造函数详细信息 Entry public Entry() 方法详情 getPath public abstract String getPath() 获取Entry的路径。 返回: 返回Entry的路径。 getType public abstract Entry.Type getType() 获取Entry的类型。 返回: 返回Entry的类型。