在BlackBerry 10上创建数据库

时间:2013-09-06 12:05:46

标签: c++ qt qml blackberry-10

我正在为Blackberry设备开发应用程序。这个程序包含一个数据库。由于API是在最后一个API版本上提供的,因此我决定使用SQLite。

我跟踪了我能找到的每个样本,但无论发生什么,我都看不到数据库。 从哪里可以检索数据。

我应该补充说我目前正在使用模拟器。

如果有人知道如何在短信应用程序中存储接收消息,那么请帮助我。

1 个答案:

答案 0 :(得分:0)

我也觉得这很棘手,记得要花很长时间才能解决问题。最后,我绝望地写了这个方便的功能:

#include <QDebug>
#include <QDir>
#include <QList>
#include <QUrl>

#include <sstream>

using namespace bb::data;
using namespace std;

void listContents(QDir &src, int depth=0) {
    // You app's dirs can be symlinked into libraries, so the depth can go very deep.
    // We limit it.
    if (3<depth) return;
    QListIterator<QFileInfo> entries(src.entryInfoList());
    std::stringstream spaces;

    // If you want to indent files by depth
//  for (int i=0; i<depth; i++) {
//      spaces << ' ';
//  }

    while (entries.hasNext()) {
        QFileInfo entry = entries.next();
        QString canpath = entry.canonicalFilePath();
        QString relpath = src.relativeFilePath(entry.fileName());
        if ((relpath == ".") || (relpath=="..")) {
            continue;
        }
        if (entry.isDir()) {
            QDir subdir(canpath);
            if (!(subdir==src)) {
                listContents(subdir, depth+1);
            }
        } else {
                qDebug() << spaces.str().c_str() << canpath.toUtf8().data();
        }
    }
}

要使用它,您必须首先从/data剥离QDir::homePath()目录:

QString appFolder(QDir::homePath());
qDebug() << "appFolder = " << appFolder;
appFolder.chop(4);

QDir listSource = appFolder + "app/native";
listContents(listSource);

此后,只需检查日志以找到数据库文件的正确路径。

但请注意,如果要写入数据库,则应将其从app/native目录复制到data目录。

相关问题