Android文件打开失败:EROFS [英] Android File open failed: EROFS

查看:179
本文介绍了Android文件打开失败:EROFS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时我得到Exception.java.io.FileNotFoundException,文件打开失败:EROFS(只读文件系统)。我有我的清单WRITE_EXTERNAL_STORAGE权限,有一段时间,当我有我的服务运行,然后我得到这些例外,很少的操作将不会成功,但如果我重新启动我的设备,那么它工作正常。
我想赶上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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆