Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android数据保存目录 我的应用程序主要是C++(使用NDK),所以我使用 fOpen, f> 等。标准函数创建和保存文件并写入其中。_Android_Filesystems_Directory - Fatal编程技术网

android数据保存目录 我的应用程序主要是C++(使用NDK),所以我使用 fOpen, f> 等。标准函数创建和保存文件并写入其中。

android数据保存目录 我的应用程序主要是C++(使用NDK),所以我使用 fOpen, f> 等。标准函数创建和保存文件并写入其中。,android,filesystems,directory,Android,Filesystems,Directory,当我使用fopen(“game.sav”,“wb”)时,它似乎是在path中创建的 /data/user/10/com.my.game/files/game.sav 我的应用程序是多用户的。因此,我希望有一个单独的文件夹,用户在其中存储他们的保存文件。而不是上面的路径,我希望有这样的路径 /data/user/10/com.my.game/files/user0/game.sav /data/user/10/com.my.game/files/user1/game.sav等 我的应用程序的前端是

当我使用
fopen(“game.sav”,“wb”)
时,它似乎是在path中创建的

/data/user/10/com.my.game/files/game.sav

我的应用程序是多用户的。因此,我希望有一个单独的文件夹,用户在其中存储他们的保存文件。而不是上面的路径,我希望有这样的路径

/data/user/10/com.my.game/files/user0/game.sav

/data/user/10/com.my.game/files/user1/game.sav

我的应用程序的前端是Java,在注册新用户时,我想创建一个文件夹
/data/user/10/com.My.game/files/user0/
。但我不知道怎么做,因为

final File newDir = context.getDir("user0", Context.MODE_PRIVATE);
结果在
/data/user/10/com.my.game/app_user0
处创建了一个不同的路径


可以在
/data/user/10/com.my.game/files/
上创建文件夹,以及如何创建文件夹?

简单方法,此代码可以根据多种情况进行更改。如果您知道您的路径与getFilesDir()得到的路径不同,那么您可以首先使用您知道的路径创建一个文件,最后两行代码仍然相同

    File file = this.getFilesDir(); // this will get you internal directory path
    Log.d("BLA BLA", file.getAbsolutePath());
    File newfile = new File(file.getAbsolutePath() + "/foo"); // foo is the directory 2 create
    newfile.mkdir();
如果您知道“文件”目录的路径:

     File newfile2 = new File("/data/data/com.example.stackoverflow/files" + "/foo2");
    newfile2.mkdir();
这两种代码都有效

工作证明:

     File newfile2 = new File("/data/data/com.example.stackoverflow/files" + "/foo2");
    newfile2.mkdir();