查看在内部存储中创建的文件夹 android

View created folder in internal storage android

我使用下面的代码在内部存储中创建了一个文件。

    ContextWrapper contextWrapper = new ContextWrapper(getApplicationContext());
    File directory = contextWrapper.getDir(filepath, 0);
    File myInternalFile = new File(directory , "MySampleFile.txt");
    //for writing
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(myInternalFile);
        fos.write("data".toString().getBytes());
        fos.close();
    } 
    catch (FileNotFoundException e1) {
        e1.printStackTrace();
    } 
    catch (IOException e) {
        e.printStackTrace();
    }
    //for reading
    String myData="";
    try {
        FileInputStream fis = new FileInputStream(myInternalFile);
        DataInputStream in = new DataInputStream(fis);
        BufferedReader br =
                new BufferedReader(new InputStreamReader(in));
        String strLine;
        while ((strLine = br.readLine()) != null) {
            myData = myData + strLine;
        }
        in.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    Toast.makeText(getApplicationContext(), myData, Toast.LENGTH_SHORT).show();//prints data

我可以读写文件。 我想知道的是如何浏览或查看文件? 使用了文件资源管理器但没有帮助

你忘了

myInternalFile.createNewFile();

UPD 我收到你的问题了。来自 doc ContextWrapper.getDir :

Retrieve, creating if needed, a new directory in which the application can place its own custom data files. You can use the returned File object to create and access files in this directory. Note that files created through a File object will only be accessible by your own application; you can only set the mode of the entire directory, not of individual files.

因此只有您的应用可以访问该文件夹。可能可以在有根设备上访问它。为了获取文件路径,只需在日志中打印它或在调试模式下检查。