问题
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!
回答1:
For picture you need to use mediaScanIntent Android Doc
After some quick research here could be a solution solution for files
回答2:
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
来源:https://stackoverflow.com/questions/31188527/as3-for-android-saving-a-file-in-the-external-storage-only-visible-when-phone