0

I´m having trouble finding my file in the device

I am saving a file in the external storage, specifically using this code

    private function saveFiles():void
    {
        var file1:File = File.applicationStorageDirectory.resolvePath("v/appstorage.doc")
        var file2:File = File.cacheDirectory.resolvePath("v/cache.doc")
        var file3:File = File.desktopDirectory.resolvePath("v/desktop.doc")
        var file4:File = File.documentsDirectory.resolvePath("v/documents.doc")
        var file5:File = File.userDirectory.resolvePath("v/userdir.doc")
        saveFile(file1)
        saveFile(file2)
        saveFile(file3)
        saveFile(file4)
        saveFile(file5)
    }

    private function saveFile(file:File):void 
    {
        var stream:FileStream = new FileStream();
        stream.open(file, FileMode.WRITE);
        stream.writeUTFBytes(body);
        stream.close();
    }

No file is visible after this when you connect your phone again, I tried killing the app, I tried reconnecting the USB cable, hitting F5 to update the folder.

The files are only visible when I restart my phone, so, my question is:

What can I do to save the file and make it visible when I save the file without restarting my phone?

The file is saved in the folder v you can access those by connecting your phone via USB after the restart, I can see desktop.doc, documents.doc and userdir.doc, the variable body is the string "Hello world" , the phones I am using is a Moto G with Lollipop, and an HTC One S with Jelly Bean

And I am using

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 

If someone could please help me with this issue, that would be great!

  • I don't have any experience with files in Android, but with a quick search, I found [this answer](http://stackoverflow.com/a/21191262/4896787) that may be of use to you. In particular, the last excerpt of code. If that only works for media, perhaps there is an equivalent for files and this will help in your search? – Joseph Roque Jul 02 '15 at 15:23
  • Thanks Joseph but im developing in AS3 – Daniel Arias Jul 02 '15 at 15:34

2 Answers2

0

For picture you need to use mediaScanIntent Android Doc

After some quick research here could be a solution solution for files

Community
  • 1
  • 1
Bxtr
  • 316
  • 1
  • 13
0

This was the answer... https://android.stackexchange.com/questions/53422/folder-on-phone-not-showing-in-windows

It did happen to me in native language as well, it seems it is related to the MTP cache

Community
  • 1
  • 1