android 保存文件到本地可见,适用于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();

}

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

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

解决方案

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值