Gerhard
Gerhard

Reputation: 145

newly created folder does not show up in Windows explorer

I am creating my app folder /Android/data/com.mycompany.myapp. It is empty at first. However it is not visible in Windows explorer. Doing this solves it:

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));

Unfortunately this is no longer supported in API 19 (4.4). What is the alternative?

For Intent.ACTION_MEDIA_SCANNER_SCAN_FILE I need to specify a file, not a folder. The same is true for MediaScannerConnection.scanFile...

Upvotes: 3

Views: 1091

Answers (1)

Gerhard
Gerhard

Reputation: 145

I implemented this work-around:

  1. create the desired folder
  2. create an empty "dummy" file in this folder
  3. announce this file to the media scanner with:

     Uri uri = Uri.parse("file://" + m_appDir + "/tmp.x");
     sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri));
    

This will make the file and the folder visible from Windows.

Upvotes: 5

Related Questions