首页 > 解决方案 > 如何为 Android 设置本地存储路径

问题描述

我尝试嵌入由 QML 的 Local Storage for Android 生成的 sqlite 文件。下面的代码适用于桌面。尽管 Android 的 assets 文件夹中有 sqlite 和 ini 文件,但该应用程序不会将数据库文件视为默认文件。我怎样才能让它工作?

main.cpp 中的代码:

QString customPath = "assets:/OfflineStorage";
QDir dir;
if(dir.mkpath(QString(customPath))){
        qDebug() << "Default path >> "+engine.offlineStoragePath();
        engine.setOfflineStoragePath(QString(customPath));
        qDebug() << "New path >> "+engine.offlineStoragePath();
    }
engine.clearComponentCache();

标签: androidqtqml

解决方案


这里已经解决了。问题是将 sqlite 和 ini 文件复制到正确的位置。


推荐阅读