admin管理员组文章数量:1356084
My (self-developed) Sudoku application generated an IOException (EACCES (Permission denied)) when I started using an API 35 emulated device in Android Studio. The problem did not occur using an API 34 emulated device. The problem occurred (among other places) in the following function when calling context.openFileOutput():
void save(Context context, String fileName) {
// Write the field as XML.
String xmlFileName = fileName.endsWith(EXT_XML) ? fileName : fileName
+ EXT_XML;
FileOutputStream xmlFos;
try {
xmlFos = context.openFileOutput(xmlFileName, Context.MODE_PRIVATE);
} catch (IOException ex) {
throw new RuntimeException(ex.getMessage());
}
serializeXml(xmlFos);
}
My (self-developed) Sudoku application generated an IOException (EACCES (Permission denied)) when I started using an API 35 emulated device in Android Studio. The problem did not occur using an API 34 emulated device. The problem occurred (among other places) in the following function when calling context.openFileOutput():
void save(Context context, String fileName) {
// Write the field as XML.
String xmlFileName = fileName.endsWith(EXT_XML) ? fileName : fileName
+ EXT_XML;
FileOutputStream xmlFos;
try {
xmlFos = context.openFileOutput(xmlFileName, Context.MODE_PRIVATE);
} catch (IOException ex) {
throw new RuntimeException(ex.getMessage());
}
serializeXml(xmlFos);
}
Share Improve this question edited Mar 30 at 11:01 David Singleton asked Mar 30 at 10:15 David SingletonDavid Singleton 1246 bronze badges1 Answer
Reset to default 0I found the cause using the Android ADB shell function. I had uploaded a series of test files to the emulated device using a script I had developed. When I listed the files using the shell, I noticed that group access was only 'r' - readable. Changing the group access to 'rw' with the following command in the ADB shell solved my problem.
chmod g+w *
Obviously there has been some internal change in the Android OS between API 34 and API 35 that has resulted in my problem.
本文标签: Android API 35 ContextopenFileOutput() generates IOExceptionStack Overflow
版权声明:本文标题:Android API 35 Context.openFileOutput() generates IOException - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743991964a2572307.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论