未报告的异常FileNotFoundException;必须被捕获或声明被抛出(未处理的异常:java.io.FileNotFoundExceptio)

时间:2018-01-11 23:43:53

标签: java android-studio

SELECT [psc].ID
FROM PeopleStatusCodes [psc], @peopleStatus [temp]
WHERE [psc].PeopleStatusID = [temp].peopleStatusID

1 个答案:

答案 0 :(得分:0)

FileNotFoundException(checked)不是RuntimeException(未选中),您必须显式处理它。

如果重写的方法抛出FileNotFoundException,则可以执行以下操作:

@Override
public void onEdittextDialogEnded(String result, String hint, EditTextDialog.Actions action)
    throws FileNotFoundException {

    if (Device.hasKitKatApi() && TextUtils.isEmpty(greatUri.getFilePath())) {
        Uri newUri = DocumentsContract.renameDocument(getContentResolver(), greatUri.getUri(), result);
        // if everything is ok
        if (newUri != null) {

否则用try和catch包围代码:

try {
    if (Device.hasKitKatApi() && TextUtils.isEmpty(greatUri.getFilePath())) {
        Uri newUri = DocumentsContract.renameDocument(getContentResolver(), greatUri.getUri(), result);
        // if everything is ok
        if (newUri != null) {
        }
    }
} catch(FileNotFoundException ex) {
}