首页 > 解决方案 > 有没有办法在 Android 中的文件上设置自定义(又名用户定义)文件属性?

问题描述

我需要设置用户定义的属性有两个原因,1-标记加密文件,2-实现像 MacOS 的 Finder 那样的标签系统。

这是我尝试过的:

Files.setAttribute(
    Paths.get("/storage/emulated/0/Download/21014040_9_Fizik_KTT.pdf"),
    "user:tagred",
    "testtesttest"
));

给出这个错误:

java.lang.UnsupportedOperationException:查看“用户”不可用

Path path = new File(filePath).toPath();
UserDefinedFileAttributeView view = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);

在这里,视图为空。

我应该改用什么?

标签: javaandroidfile-attributes

解决方案


推荐阅读