【问题标题】:write file in adobe air for android在 adobe air for android 中写入文件
【发布时间】:2013-01-17 20:53:29
【问题描述】:

你好 evrey 身体,我已经非常努力地向 android 写入文件,但到目前为止还没有 secceus。 这是我正在使用的代码。

function writeAirFile():void
{
    // Change the folder path to whatever you want plus name your mp3
    // If the folder or folders does not exist it will create it.
    var file:File = new File("/mnt/sdcard/new/new.apk");
     //file.nativePath = "/mnt/sdcard/new/new.apk";
     trace(file.nativePath);
    fileStream.open(file, FileMode.WRITE);
    fileStream.writeBytes(fileData, 0, fileData.length);
    fileStream.close();
    trace("The file is written.");
    trace(file.nativePath);

}

uts 需要工作,但事实并非如此。 我已经为本地存储写入添加了权限 请问我需要帮助 非常感谢大家的帮助!

【问题讨论】:

    标签: android flash file air


    【解决方案1】:

    指出自定义目录不是最佳实践,您可以使用File.applicationStorageDirectory,因此无需担心安全和权限相关问题。

        var file:File = File.applicationStorageDirectory.resolvePath("new/new.apk");
        fileStream.open(file, FileMode.WRITE);
        fileStream.writeBytes(fileData, 0, fileData.length);
        fileStream.close();
        trace("The file is written.");
        trace(file.nativePath); // you can find where it is stored.
    

    建议始终使用异步模式文件操作,这样即使文件太大也不会发生 UI 冻结。

    【讨论】:

      猜你喜欢
      • 2020-02-06
      • 2015-10-21
      • 1970-01-01
      • 1970-01-01
      • 2011-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-16
      相关资源
      最近更新 更多