title: Files not visible from my PC
body: <p>I have an android 4.3 device and often connect it to my PC via USB so that I can view files created by one of my apps. Strangely though, it seems that not all files on the android file system are visible. After much searching I came across <a href="http://www.grokkingandroid.com/adding-files-to-androids-media-library-using-the-mediascanner/" rel="nofollow">this page</a> which (correct me if I'm wrong) suggests that if I call MediaScannerConnection.scanFile, with the path I'm interested in, then it would make all files in those directories visible. I have implemented the code as follows:</p>
  
  <pre><code>void make_files_in_directory_visible_on_pc(String directory)
  {
      Log.i("xx","make_files_in_directory_visible_on_pc: dir=["+directory+"]");
      MediaScannerConnection.scanFile(
            getApplicationContext(),
            new String[]{ directory }, // array of paths
            null, // mime types
            new OnScanCompletedListener() {
               @Override
               public void onScanCompleted(String path, Uri uri)
               {
                  Log.i("xx","file " + path + " was scanned successfully: " + uri);
               }
            });
  }
  </code></pre>
  
  <p>My app saves its files in Environment.getExternalStorageDirectory().getAbsolutePath() which, on my device, is "/storage/emulated/0".</p>
  
  <p>When I execute this from my app I see the following in the logs:</p>
  
  <pre><code>file /storage/emulated/0 was scanned successfully: content://media/external/file/2552
  </code></pre>
  
  <p>After the code has run there is no change to the list of files visible from my PC, many files are still missing.
  Any ideas?</p>
  
  <p><strong>EDIT:</strong> FYI, I do not have a file called "2552" on that directory, or anywhere else on my device.</p>
  
  <p><strong>EDIT:</strong> If I execute the following:</p>
  
  <pre><code>MediaScannerConnection.scanFile(this, new String[] {Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+name_of_individual_file}, null, null);
  </code></pre>
  
  <p>Then that single file does indeed become visible, but I want to achieve this for <em>all</em> files in the directory.</p>