0

I am making an app that stores a WAV file. It makes a folder in external storage on my phone and then stores it. It does this successfully. However when I plug in my phone to the computer via USB on MTP, the folder and any files made by my application don't show. What should I do?

I cannot use the following code because my API min cannot support DIRECTORY_DOCUMENTS. Is the trick to making them viewable on the computer just changing the filepath? If so, what should I enter for the file path? :

protected String mDir = Environment.DIRECTORY_DOCUMENTS;
protected File mPath = Environment.getExternalStoragePublicDirectory(mDir);

protected void writeLogFile(String filename) {
    File f = new File(mPath, filename + ".txt");
    f.getParentFile().mkdirs();
    try (BufferedWriter bw = new BufferedWriter(new FileWriter(f, false))) {

        // Details omitted.

    } catch (Exception e) {
        e.printStackTrace();
        return;
    }
    makeText("Wrote " + f.getAbsolutePath());
}

2 Answers2

1

Clear the media storage cache from settings and then restart your phone . It occurs frequently over USB connection as the database has not been refreshed .

Rishabh Maurya
  • 1,448
  • 3
  • 22
  • 40
-1

All I needed to do was restart my phone and re-plug it in.