找不到getApplicationDocumentsDirectory()提供的路径 [英] Cannot find the path provided by getApplicationDocumentsDirectory()

查看:224
本文介绍了找不到getApplicationDocumentsDirectory()提供的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试了这个flutter应用程序示例: https://github.com/tensor-programming/flutter_read_write_file_and_path

但是,使用文件管理器(Solid Explorer)浏览设备时,找不到此示例创建的文件"db.txt".

 最终路径=等待localPath; 

我检查了许多文件夹,包括:

  • /storage/emulated/0(= sdcard)
  • sdcard/Android/data
  • sdcard/数据

此文件在哪里?我应该扎根我的设备以查找/查看它吗?

要在"path"变量之后添加什么字符串以到达下载"文件夹?或者,如何获取下载"文件夹的绝对路径?

设备:GALAXY S8 + SM-G955F.Android 8.0.不扎根.Flutter beta v0.5.1.Dart 2.0.0-dev.58.0.Windows 10.谢谢和问候

解决方案

如果您正在使用设备上安装的文件浏览器应用程序,那么我认为您将无法访问为其他文件存储的文件应用程序在其应用程序文档"目录中.这是将应用程序彼此隔离的安全模型的一部分.

如果您使用Android Studio来构建应用并将其部署到设备上,则可以访问查看> 工具Windows > 设备文件资源管理器,并将您的设备通过USB连接到PC,以访问这些文件.

对于我自己的Flutter应用程序,对于您给出的示例,我发现相关路径为/data/usr/0/…/app_flutter,这将是/data/usr/0/com.example.localstorageexample/app_flutter

(如果您尚未使用Android Studio部署您引用的演示,那么如何在设备上获取它?)

I tested this flutter app example: https://github.com/tensor-programming/flutter_read_write_file_and_path

But, browsing my device with a file-manager (Solid Explorer), I cannot find the file "db.txt" created by this example.

final path = await localPath;

I checked in many folders including:

  • /storage/emulated/0 (= sdcard)
  • sdcard/Android/data
  • sdcard/data

Where is this file? Should I root my device to find/see it?

What string to add after the "path" variable to reach the Download folder? Or, how to get the absolute path to the Download folder?

Device: GALAXY S8+ SM-G955F. Android 8.0. Not Rooted. Flutter beta v0.5.1. Dart 2.0.0-dev.58.0. Windows 10. Thanks and regards

解决方案

If you're using a file explorer app installed on the device, then I don't believe you'll be able to access the files stored for a different app in it's Application Documents directory. This is part of the security model that isolates apps from each other.

If you have used Android Studio to build and deploy the app to your device, then you can got to View > Tool Windows > Device File Explorer with your device attached to your PC via USB to access these files.

I find for my own Flutter apps that the relevant path is /data/usr/0/…/app_flutter for the example you gave, this would be /data/usr/0/com.example.localstorageexample/app_flutter

(If you haven't used Android Studio to deploy the demo you reference, how did you get it on your device?)

这篇关于找不到getApplicationDocumentsDirectory()提供的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆