0

我正在关注这个例子:https ://stackoverflow.com/a/41713258/2330482

但是,重新启动应用程序后无法读取该文件,因此我在设备管理器中进行了检查 - 该文件夹未出现在 /opt/usr/home/owner/apps_rw/org.example.basicui/data/ 中。我已经cd进入.basicui目录并ls - l给出

sh-3.2$ cd apps_rw                                                             
sh-3.2$ cd org.example.basicui
sh-3.2$ ls -l
ls: cannot access cache: Permission denied
ls: cannot access data: Permission denied
total 8
lrwxrwxrwx 1 app_fw app_fw   60 Sep  2 21:31 author-signature.xml -> /opt/usr/globalapps/org.example.basicui/author-signature.xml
lrwxrwxrwx 1 app_fw app_fw   43 Sep  2 21:31 bin -> /opt/usr/globalapps/org.example.basicui/bin
d????????? ? ?      ?         ?            ? cache
d????????? ? ?      ?         ?            ? data
lrwxrwxrwx 1 app_fw app_fw   43 Sep  2 21:31 lib -> /opt/usr/globalapps/org.example.basicui/lib
lrwxrwxrwx 1 app_fw app_fw   43 Sep  2 21:31 res -> /opt/usr/globalapps/org.example.basicui/res
drwxr-xr-x 3 owner  users  4096 Sep  2 21:31 shared
lrwxrwxrwx 1 app_fw app_fw   58 Sep  2 21:31 tizen-manifest.xml -> /opt/usr/globalapps/org.example.basicui/tizen-manifest.xml
sh-3.2$ whoami
owner

我的代码如下:

char* get_write_filepath(char *filename)
{

    char write_filepath[1000] = {0,};
    char *resource_path = app_get_data_path(); // get the application data directory path
    if(resource_path)
    {
        snprintf(write_filepath,1000,"%s%s",resource_path,filename);
        free(resource_path);
    }

    return write_filepath;
}

static char* write_file(const char* filepath, const char* buf)
{

    FILE *fp;
    fp = fopen(filepath,"w");
    fputs(buf,fp);
    fclose(fp);

    dlog_print(DLOG_DEBUG, "AAAMYTAG", "written");

}


void saveExampleFile() {
    dlog_print(DLOG_DEBUG, "AAAMYTAG", "save example file");

            char *filepath;
            filepath=get_write_filepath("d.txt");
            write_file(filepath,"TEST");
}

static void //B Button
    btn_go_cb(void *data, Evas_Object *obj, void *event_info)
    {
        dlog_print(DLOG_INFO, "AAAMYTAG", "GO successful.");

        saveExampleFile();
}

我哪里错了?文件夹不应该data是永久的吗?这可能是模拟器错误吗?

4

2 回答 2

0

您是否在 config.xml 中设置了权限?认为你需要:tizen:privilege name="http://tizen.org/privilege/filesystem.read" tizen:privilege name="http://tizen.org/privilege/filesystem.write"

于 2019-09-03T17:19:58.343 回答
0

问题在于Run configurations(运行播放按钮旁边)->“启用更新模式”。

这使数据保持不变,默认情况下被禁用。让它沉入其中。三星不是通过启动保留数据,而是在您希望删除已安装的应用程序时将其卸载,而是默认删除数据并选择保留数据。这是迄今为止最荒谬的操作系统。我永远不会理解这背后的意图,以及必须使用 C 和 C++ 而不是适当的高级语言。难怪没有适用于 Tizen 的应用程序。

于 2019-09-04T21:51:14.563 回答