Where is the location using android File access with cordova/phonegap -


i started using phonegap android app development. trying write file using code (following phonegag example).

document.addeventlistener("deviceready", ondeviceready, false);  // cordova ready // function ondeviceready() {     window.requestfilesystem(localfilesystem.persistent, 0, gotfs, fail); }  function writetext(file, text) {     filename = file;     texttowrite = text;     window.requestfilesystem(localfilesystem.persistent, 0, gotfs, fail); }  function gotfs(filesystem) {     filesystem.root.getfile(filename, {create: true, exclusive: false}, gotfileentry, fail); }  function gotfileentry(fileentry) {     fileentry.createwriter(gotfilewriter, fail); }  function gotfilewriter(writer) {   writer.seek(writer.length);   writer.write(texttowrite);   console.log("output: " + texttowrite); }  function fail(error) {     console.log(error.code); } 

in android emulator eclipse debugger, can see lines executed (log line printed out). no errors anywhere. however, not find file in system. should file go? can @ in windows?

here how call writer. writetext("test.txt", "ending ...");

where file test.txt? or, maybe got wrong?

many thanks!

i believe phonegap place file in /mnt/storage/sdcard0 on device.

for emulator can find doing -

  1. switch ddms perspective
  2. select emulator in devices list, sdcard want explore.
  3. open file explorer tab on right hand side.
  4. expand tree structure. mnt/sdcard/

enter image description here

i suggest putting callback function inside gotfilewriter know when write has finished -

function gotfilewriter(writer) {     writer.onwriteend = function(evt) {         console.log('write has finished');     };     writer.seek(writer.length);     writer.write(texttowrite); } 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -