【问题标题】:Can't find folder on tablet but on phone [Android]在平板电脑上但在手机上找不到文件夹 [Android]
【发布时间】:2017-03-18 20:57:37
【问题描述】:

我正在尝试在我的平板电脑上找到一个文件夹。

我可以使用此代码在我的 PHONE 上找到文件夹:

 File settingsFolder = new File(Environment.getExternalStorageDirectory(), settingsFileDirectory);

我可以在手机上找到文件夹,但在平板电脑上找不到,这是怎么回事?

在同一目录下创建了一个同名文件夹(同下载文件夹)。

问候

【问题讨论】:

  • “查找文件夹”是什么意思?您正在创建一个 File 对象...然后根据您问题中的单行代码对它不做任何事情。
  • 你的平板和手机的sdk版本是多少?

标签: java android file android-studio directory


【解决方案1】:

代替

Environment.getExternalStorageDirectory()

使用

context.getFilesDir().getPath() + ....destination...

例子

new File(
context.getFilesDir().getPath()
+ "/settings"
+ "/happyness");

【讨论】:

  • 嘿 Mohammed,我现在正在尝试使用您的代码在手机/平板电脑的下载目录中获取一个文件,但我的应用程序崩溃了。字符串路径 = this.getFilesDir().getPath()+"/Download";
  • @Jannick 请用错误和代码行更新您的帖子,以便我可以更好地帮助您:)
猜你喜欢
  • 1970-01-01
  • 2011-08-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-01
  • 2018-12-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多