Android文件打开失败:EROFS [英] Android File open failed: EROFS
问题描述
我想赶上Exception.java.io.FileNotFoundException异常,并以编程方式重新启动我的设备。我的设备是根源,所以我以编程方式执行su -c reboot。
我需要知道如何捕捉文件打开失败:EROFS异常并触发重启?
< $(){
做任何
} catch(FileNotFoundException ex){
if(EROFS(只读文件系统)。equals(ex.getMessage())) {
调用代码重新启动
}
}
您可以更换错误信息甚至跳过它
编辑:基于评论
$ $ $ $ $ $ ((例如,FileNotFoundException)&&EROFS(只读文件系统)。 ex.getMessage())){
重新启动
的调用代码}
}
Sometimes I get Exception.java.io.FileNotFoundException, file open failed: EROFS ( Read- only file System) . I have WRITE_EXTERNAL_STORAGE permission in my manifest, once in a while when I have my services running then I get these exceptions and few operations will not be succeeded but if I reboot my device then it works fine. I want to catch "Exception.java.io.FileNotFoundException" exception and reboot my device programmatically. My device is rooted one so I programmatically execute "su -c reboot".
I need to know how to catch " File open failed: EROFS " exception and trigger a reboot ??
Will solve your problem this:
try{
do whatever
}catch(FileNotFoundException ex){
if("EROFS ( Read- only file System)".equals(ex.getMessage())){
call code for reboot
}
}
You can replace the error message or even skip it
Edit: - based on comment
try{
do whatever
}catch(IOException ex){
if((ex instanceof FileNotFoundException) && "EROFS ( Read- only file System)".equals(ex.getMessage())){
call code for reboot
}
}
这篇关于Android文件打开失败:EROFS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!