react-native-fs.android中实际的文档目录路径

Pon*_*rez 3 android reactjs react-native react-native-fs

我尝试了创建文件的代码,我创建了两个文件,那就是

    // require the module
    var RNFS = require('react-native-fs');

    // create a path you want to write to
    var path = RNFS.DocumentDirectoryPath + '/test.txt';

    // write the file
    RNFS.writeFile(path, 'Lorem ipsum dolor sit amet', 'utf8')
    .then((success) => {
    console.log('FILE WRITTEN!');
    })
    .catch((err) => {
    console.log(err.message);
    });
Run Code Online (Sandbox Code Playgroud)

我用该代码创建了两个文件。但我看不到实际创建的文件。它究竟保存在哪里?

Dar*_*ter 7

您在手机上看不到它们。如果您想存储可以看到的文件,请使用ExternalDirectoryPath 或ExternalStorageDirectoryPath。我也在寻找类似问题的答案,但找不到任何答案。所以,我尝试了所有这些路径。我的猜测是 DocumentDirectoryPath 用于存储您的应用程序的私有数据。我对 Android 开发还很陌生,所以请对我的话持保留态度。