【问题标题】:react-native-fs.the actual document directory path in androidreact-native-fs.android中的实际文档目录路径
【发布时间】:2018-01-25 15:27:38
【问题描述】:

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

    // 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);
    });

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

【问题讨论】:

  • 你可以试试改常量吗,var path = RNFS.ExternalStorageDirectoryPath + '/test.txt';
  • 哦。这条路径看起来很熟悉:D 感谢@HSBP 的建议,我暗示了它的去向
  • 但是DocumentDirectoryPath 保存在哪里?

标签: android reactjs react-native react-native-fs


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-07
    • 1970-01-01
    • 2012-04-12
    • 1970-01-01
    • 2014-10-01
    • 2013-02-02
    • 1970-01-01
    • 2015-11-25
    相关资源
    最近更新 更多