在我的 android 应用程序中,我创建了一个文件并将一些测试文本写入其中:
File externalPath = getExternalFilesDir(null);
File importPath = new File(externalPath, "pd-import");
if(!importPath.exists()) {
Log.d(this.getClass().getSimpleName(), "Create import dir: " + importPath.getAbsolutePath());
importPath.mkdirs();
}
File readme = new File(importPath, "README.txt");
try {
FileWriter fw = new FileWriter(readme);
fw.write("This is a test");
fw.flush();
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
这将写入文件,该文件可以使用B1 文件管理器等 android 文件浏览器进行批准。它被写入HOME/Android/data/JAVA_PACKAGE_NAME/files/pd-import/README.txt
logcat 显示: D/MainActivity:创建导入目录:/storage/emulated/0/Android/data/JAVA_PACKAGE_NAME/files/pd-import
当我通过 USB 将测试代码的 Nexus 连接到我的 Ubuntu 笔记本电脑时,我会看到所有其他应用程序数据目录,例如NEXUS 5/Interner Speicher/Android/data/ALL_THE_OTHER_JAVA_PACKAGE_NAMEs(“Interner Speicher”代表:内部存储器) . 但未列出我的应用程序的文件夹未列出。
我是否需要设置一些额外的 medatdata/information/whatever,才能在 MTP 连接上列出文件夹?有什么建议吗?