适用于Android的AS3,将文件保存在外部存储中(仅在手机重启时可见) [英] AS3 for Android, Saving a file in the external storage (Only visible when phone restarts)

查看:242
本文介绍了适用于Android的AS3,将文件保存在外部存储中(仅在手机重启时可见)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在设备中找到我的文件

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();
    }

此后再次连接手机后看不到文件,我尝试杀死在应用程序中,我尝试重新连接USB电缆,按F5键更新文件夹。

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?

文件保存在文件夹v中,您可以在重启后通过USB连接手机来访问这些文件夹,我可以看到desktop.doc,documents.doc和userdir.doc,变量主体为字符串 Hello world,
我正在使用的手机是带有棒棒糖的Moto G和带有果冻豆的HTC One S

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

我正在使用

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

如果有人可以帮助我解决这个问题,那就太好了!

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

推荐答案

这就是答案... https://android.stackexchange.com/questions/53422/folder-on-phone-not-showing-in-windows

我也确实以母语出现过,这似乎与MTP缓存有关

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

这篇关于适用于Android的AS3,将文件保存在外部存储中(仅在手机重启时可见)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆