HarmonyOS鸿蒙Next中本地模拟器getRdbStore获取失败,也没有报错信息
HarmonyOS鸿蒙Next中本地模拟器getRdbStore获取失败,也没有报错信息
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
import { relationalStore } from '@kit.ArkData'
import { BusinessError } from '@kit.BasicServicesKit';
const DOMAIN = 0x0000;
let store: relationalStore.RdbStore | undefined = undefined;
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
}
onDestroy(): void {
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage): void {
// Main window is created, set main page for this ability
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
const STORE_CONFIG: relationalStore.StoreConfig = {
name: "RdbTest.db",
securityLevel: relationalStore.SecurityLevel.S3
};
relationalStore.getRdbStore(this.context, STORE_CONFIG, (err: BusinessError, rdbStore: relationalStore.RdbStore) => {
store = rdbStore;
if (err) {
console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
return;
}
console.info('Get RdbStore successfully.');
})
windowStage.loadContent('pages/Index', (err) => {
if (err.code) {
hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
return;
}
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
});
}
onWindowStageDestroy(): void {
// Main window is destroyed, release UI related resources
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground(): void {
// Ability has brought to foreground
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground(): void {
// Ability has back to background
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
}
}
报错信息:
更多关于HarmonyOS鸿蒙Next中本地模拟器getRdbStore获取失败,也没有报错信息的实战教程也可以访问 https://www.itying.com/category-93-b0.html
2 回复
您好,您的问题需要进一步分析,请您通过在线提单进一步解决:https://developer.huawei.com/consumer/cn/support/feedback/#/,感谢您的反馈和支持。
更多关于HarmonyOS鸿蒙Next中本地模拟器getRdbStore获取失败,也没有报错信息的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
在HarmonyOS鸿蒙Next中,getRdbStore
获取失败但未报错,可能原因包括:
- 数据库路径或配置错误;
- 权限未正确设置;
- 数据库文件损坏或不存在。
建议检查数据库路径、确保权限正确,并验证数据库文件完整性。若问题依旧,可尝试重启模拟器或重新创建数据库。