为什么在 DOWNLOADS 文件夹中看到历史记录,但文件已经消失并且文件实际上没有显示
Why seeing history in DOWNLOADS folder, but the files are already gone and the files actually there not showing
我正在启动一个这样的选择器(我尝试了不同的东西,如注释掉的行所示):
Intent intent = new Intent();
//sets the select file to all types of files
intent.setType("application/pdf|application/msword|text/*");
//intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
//intent.addCategory(Intent.CATEGORY_OPENABLE);
//allows to select data and return it
//intent.setAction(Intent.ACTION_GET_CONTENT); // show more
intent.setAction(Intent.ACTION_OPEN_DOCUMENT); //show less
activity.startActivityForResult(Intent.createChooser(intent, "Select File"), PICK_FILE_REQUEST);
使用这段代码,出现的菜单是这样的:
打开自
音频
最近
下载
银河 S6 边缘
开车
如果我点击“下载”菜单,它会显示文件的历史记录,但在 phone?
如果我浏览到 "Galaxy S6 edge" 并从那里进入“下载”文件夹,我可以在 phone 中看到文件。
我注意到第一种情况是 "Downloads" 结尾有一个“s”,第二种情况是 "Download".
我该如何解决这个问题?有没有办法以编程方式完全删除出现在菜单中的 "Downloads" 文件夹?
似乎使用这行代码会默认在汉堡菜单中显示"Internal storage":
intent.putExtra("android.content.extra.SHOW_ADVANCED", true);
来自url:How to show the "internal storage" option in an ActionOpenDocument intent by default
关于"Downloads"历史文件夹:我之前的观察并不准确。事实证明,下载到 phone 中的 "Download" 文件夹中的文件也会出现在 "Downloads" 历史文件夹中,并且从 "Download" 文件夹中手动删除文件时不会删除它自动从 "Downloads" 历史文件夹中。
所以看起来 "Downloads" 历史文件夹的行为类似于 short-cut,并且当手动删除指向的实际文件时它不会自动清除。这很可能是预期行为。我猜想与 Windows 中的 short-cut 类似。因此,当在 "Downloads" 历史文件夹中选择一个已被删除的文件时,将按预期生成 NullPointerException,我们应该处理此异常。
我正在启动一个这样的选择器(我尝试了不同的东西,如注释掉的行所示):
Intent intent = new Intent();
//sets the select file to all types of files
intent.setType("application/pdf|application/msword|text/*");
//intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
//intent.addCategory(Intent.CATEGORY_OPENABLE);
//allows to select data and return it
//intent.setAction(Intent.ACTION_GET_CONTENT); // show more
intent.setAction(Intent.ACTION_OPEN_DOCUMENT); //show less
activity.startActivityForResult(Intent.createChooser(intent, "Select File"), PICK_FILE_REQUEST);
使用这段代码,出现的菜单是这样的:
打开自
音频
最近
下载
银河 S6 边缘
开车
如果我点击“下载”菜单,它会显示文件的历史记录,但在 phone?
如果我浏览到 "Galaxy S6 edge" 并从那里进入“下载”文件夹,我可以在 phone 中看到文件。
我注意到第一种情况是 "Downloads" 结尾有一个“s”,第二种情况是 "Download".
我该如何解决这个问题?有没有办法以编程方式完全删除出现在菜单中的 "Downloads" 文件夹?
似乎使用这行代码会默认在汉堡菜单中显示"Internal storage":
intent.putExtra("android.content.extra.SHOW_ADVANCED", true);
来自url:How to show the "internal storage" option in an ActionOpenDocument intent by default
关于"Downloads"历史文件夹:我之前的观察并不准确。事实证明,下载到 phone 中的 "Download" 文件夹中的文件也会出现在 "Downloads" 历史文件夹中,并且从 "Download" 文件夹中手动删除文件时不会删除它自动从 "Downloads" 历史文件夹中。
所以看起来 "Downloads" 历史文件夹的行为类似于 short-cut,并且当手动删除指向的实际文件时它不会自动清除。这很可能是预期行为。我猜想与 Windows 中的 short-cut 类似。因此,当在 "Downloads" 历史文件夹中选择一个已被删除的文件时,将按预期生成 NullPointerException,我们应该处理此异常。