【问题标题】:How to write to a local file in js (phonegap)如何在js中写入本地文件(phonegap)
【发布时间】:2012-09-23 16:10:11
【问题描述】:

您好,我正在尝试使用$.twFile.save 在本地文本文件中写入一些文本,但结果什么也没有。我尝试使用我的 phonegap 应用在安卓设备上书写。

我使用下面的代码

     t.executeSql('SELECT * FROM flatmetric', [], 
      function(t, metric) {
       var mymetric = metric.rows.length;

       for (i = 0 ; i < mymetric ; i += 1) {
        var row = metric.rows.item(i);

          sendmetric += row.buildingcode;
          sendmetric += row.flatno; 

       $.twFile.save("file:///mnt/sdcard/koinoxrista/Collector.txt", sendmetric) ;
      }
     )

我哪里错了?

除了twFile还有其他方法吗?

【问题讨论】:

    标签: javascript file jquery-mobile text


    【解决方案1】:

    在 WebKit 浏览器中,twFile 使用 Java 小程序 TiddlySaver.jar 来完成文件系统交互。但是,Android 中的 WebView 不能使用这个或任何 Java 小程序。

    尝试使用 phonegap 文件 API: http://docs.phonegap.com/en/2.6.0/cordova_file_file.md.html#File

    参见 StackOverflow: Writing and reading file in phonegap

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-24
      • 2017-03-24
      • 2016-12-14
      • 2013-10-23
      • 1970-01-01
      • 2020-07-04
      相关资源
      最近更新 更多