3

I have a simple application that attempts to save some data to external storage on Android device (Nexus 4) to be later retrieved on PC (Windows or Mac).

The writing succeeds but when i try to retrieve the file using Android File Transfer on Mac or by Explorer on Windows the MyApp directory just isn't there.

If i use 'Root Explorer' app on the device itself i can see the directory and the file and all permissions look ok.

The application code is along the following lines:

        File extStorageDir = Environment.getExternalStorageDirectory();
        File path = new File(extStorageDir, "MyApp");
        File file = new File(path, "TestFile.txt");

        OutputStream os = new FileOutputStream(file);

            // ... write something

        os.close();

Ideas appreciated.

AlexStack
  • 39
  • 1
  • 2
  • see [enter link description here][1] [1]: http://stackoverflow.com/questions/8888451/android-write-on-external-storage-using-getexternalstoragepublicdirectorystrin – Daniele75 Mar 25 '14 at 15:29
  • see [enter link description here][1] [1]: http://stackoverflow.com/questions/8888451/android-write-on-external-storage-using-getexternalstoragepublicdirectorystrin – Daniele75 Mar 25 '14 at 15:30

2 Answers2

1

see here

Use the app sd scanner, it seems to work on my Nexus 7 with android kitkat

Community
  • 1
  • 1
2ni
  • 507
  • 1
  • 5
  • 13
0

I experienced similar problem with Android 4 and Mac os. I guess that you might be in the same situation. The solution was to rescan the sd storage using SDrescan.

This is described here: Nexus 4 not showing files via MTP

Community
  • 1
  • 1
bart
  • 2,378
  • 2
  • 19
  • 21
  • 2
    Thanks! this code: `sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(file)));` resolved the problem – AlexStack Aug 20 '13 at 19:09
  • Thanks!ctx.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(file))); worked for me (I'm testing my app with Android 4.4 and Mac) – eento May 28 '14 at 17:58