{"record":{"id":"ce93a2b903bb6a5a","repo":"MuntashirAkon/AppManager","slug":"cannot-find","errorCode":null,"errorMessage":"Cannot find ","messagePattern":"Cannot find ","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/io/PathImpl.java","lineNumber":472,"sourceCode":"        }\n        return new PathImpl(context, t);\n    }\n\n    @Nullable\n    public Path getParent() {\n        DocumentFile file = getRealDocumentFile(documentFile).getParentFile();\n        return file == null ? null : new PathImpl(context, file);\n    }\n\n    public boolean hasFile(@NonNull String displayName) {\n        return findFileInternal(documentFile, displayName) != null;\n    }\n\n    @NonNull\n    public Path findFile(@NonNull String displayName) throws FileNotFoundException {\n        DocumentFile nextPath = findFileInternal(documentFile, displayName);\n        if (nextPath == null) {\n            throw new FileNotFoundException(\"Cannot find \" + this + File.separatorChar + displayName);\n        }\n        return new PathImpl(context, nextPath);\n    }\n\n    @NonNull\n    public Path findOrCreateFile(@NonNull String displayName, @Nullable String mimeType) throws IOException {\n        displayName = Paths.sanitize(displayName, true);\n        if (displayName == null) {\n            throw new IOException(\"Empty display name.\");\n        }\n        if (displayName.indexOf(File.separatorChar) != -1) {\n            throw new IllegalArgumentException(\"Display name contains file separator.\");\n        }\n        DocumentFile documentFile = getRealDocumentFile(this.documentFile);\n        if (!documentFile.isDirectory()) {\n            throw new IOException(\"Current file is not a directory.\");\n        }\n        String extension = null;","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/io/PathImpl.java#L454-L490","documentation":"PathImpl.findFile(displayName) throws FileNotFoundException(\"Cannot find <this>/<displayName>\") when findFileInternal locates no child with that name under the current path. It is a strict lookup: unlike findOrCreateFile, it never creates the entry. The message embeds the full attempted path.","triggerScenarios":"Calling findFile with a name that does not exist as a direct child — wrong name, wrong case, missing extension, or the entry lives in a different directory.","commonSituations":"Assuming files persist after app-data clear or reinstall; name-case mismatch (SAF can be case-sensitive depending on provider); looking up \"notes\" when the actual file is \"notes.txt\"; stale cache of file names.","solutions":["Check hasFile(displayName) first and handle absence gracefully.","Use findOrCreateFile if the file should be created when missing.","Include the correct extension in displayName, or resolve the exact name by listing children.","Catch FileNotFoundException and fall back to scanning the directory for a case-insensitive match."],"exampleFix":"// before\nPath p = path.findFile(\"config.json\"); // FileNotFoundException\n// after\nPath p = path.hasFile(\"config.json\") ? path.findFile(\"config.json\") : path.findOrCreateFile(\"config\", \"application/json\");","handlingStrategy":"try-catch","validationCode":"if (!path.hasFile(displayName)) { /* handle absence before lookup */ }","typeGuard":null,"tryCatchPattern":"try {\n    return path.findFile(name);\n} catch (FileNotFoundException e) {\n    return path.findOrCreateFile(baseName, mime); // create-or-fallback\n}","preventionTips":["Prefer hasFile() for existence probes","Include the real extension in lookups","Re-list directory contents after external changes"],"tags":["android","filesystem","file-not-found","lookup"],"backgroundTag":"file-not-found","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}