android - 如何使用较低 API 的 java.nio 中的 toAbsolutePath 和 Paths.get
问题描述
我有一个应用程序需要在电子邮件中发送多个图像附件。要发送图像,我需要一个绝对路径。为此,我使用函数.toAbsolutePath
和Paths.get
from java.nio
。这两个功能仅适用于API 26
或更高版本。在我看来,它们就像是非常基本的功能,所以我不知道为什么它们不支持较低的 API。有什么方法可以让他们使用 lowerAPIs
吗?
realPath1 = Paths.get("storage/emulated/0/Android/data/com.example.abbmalfunctionreport/cache/$image1").toAbsolutePath()
解决方案
File.getAbsolutePath()
从 API-1 开始可用。
您可能还应该使用Environment
类,请参阅如何在 Android 中获取内部存储的绝对路径
推荐阅读
- hadoop - 当我在 Hive 中使用 OpenCSVSerde 时,为什么所有列都被创建为字符串?
- java - IntelliJ Idea 高级搜索包含某个单词的类中的关键字
- c# - 如何为实体对象上下文设置命令超时
- javascript - 在 Jasmine 中测试属性的当前值
- python - Numpy:将几列与一列相乘
- python - python中的subprocess.call出错
- netflix-zuul - `zuul.ignored-services` 的有效模式
- javascript - Cypress.io:无论如何要测试特定的滚动量?
- angular - AOT 编译 Angular 5 应用程序时出现无效属性名称警告
- python - 在python中组合2个列表列表