简体   繁体   English

在Android自定义Rom中创建文件夹

[英]Creating Folder in Android Custom Rom

I'm building an Android custom ROM with an additional logging mechanism for a research project. 我正在为研究项目构建带有附加日志记录机制的Android自定义ROM。 My customized Android source code contains file logging via PrintWriter(filename) . 我的自定义Android源代码包含通过PrintWriter(filename)文件记录。 So far it works fine, but now I want to be able to grab its output from a concurrently developed App. 到目前为止,它工作正常,但现在我希望能够从同时开发的App中获取其输出。

The problem is: When the PrintWriter creates the a new log file, it is created with rw------- permission and so I'm not able to read the file from my App. 问题是:当PrintWriter创建一个新的日志文件时,它是使用rw-------权限创建的,因此我无法从我的App中读取该文件。 What would be the best way to make that work? 使该工作最佳的方法是什么?

I found the solution by myself. 我自己找到了解决方案。 It works with the java methods of the File class, but you have to invoke these after actually creating the file, which is in my opinion not straightforward, because I expected it to work like setting some attributes and then actually creating the file with these specified attributes. 它可以与File类的java方法一起使用,但是您必须实际创建文件之后调用这些方法,我认为这并不简单,因为我希望它的工作方式类似于设置一些属性,然后使用指定的属性实际创建文件属性。 Here is an example of setting Read/Write/Execute permissions for everyone for a specific file: 这是为每个人设置特定文件的读取/写入/执行权限的示例:

File file = new File("logs/log.txt");
file.createNewFile();
file.setWritable(true, false);
file.setReadable(true, false);
file.setExecutable(true, false);
PrintWriter writer = new PrintWriter(file);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM