Hi Hugh,
----- Original Message -----
> From: "Hugh Tay" <[email protected]>
> To: [email protected]
> Sent: Wednesday, January 22, 2014 8:27:41 PM
> Subject: Re: [b2g] Trouble accessing the SD card from the Emulator build
>
> Oh wow, you're Dave Hylands!
>
>
> The only previous info I could find on the Emulator SD-card came from your
> Bugzilla thread - https://bugzilla.mozilla.org/show_bug.cgi?id=828063
>
> Glad to finally meet you. =)
Good to meet you too!
...snip...
> I copied the app dir into {B2G}/gaia/apps and did ./build.sh to install the
> app into the Emulator build.
>
> My relevant code segment looks like this:
>
> ---
>
> var sdcard = navigator.getDeviceStorage("sdcard");
>
> var fname = "testfile";
> var file = new Blob( ["Hello, World"], {type: "text/plain"} );
> var request = sdcard.addNamed(file, fname);
>
> request.onsuccess = function()
> {
> alert("File created: " + fname);
> }
> request.onerror = function()
> {
> alert("Unable to create file: " + this.error);
> }
>
> ---
>
> Sadly, neither alerts were triggered.
So I copied your code snippet into my ds-test app and edited ds_doit to call
ds_test2() and it seems to be working fine.
function ds_test2() {
try {
var sdcard = navigator.getDeviceStorage("sdcard");
var fname = "testfile";
var file = new Blob( ["Hello, World"], {type: "text/plain"} );
log("About to create file '" + fname + "'");
var request = sdcard.addNamed(file, fname);
request.onsuccess = function()
{
log("File created: " + fname);
alert("File created: " + fname);
}
request.onerror = function(e)
{
log("Unable to create file: " + fname);
log("Reason: " + e.target.error.name);
alert("Unable to create file: " + fname);
}
} catch (e) {
log('ds_test2: caught an error');
log(e);
log(e.stack);
}
}
So I'm, not sure why your onsuccess or onerror isn't being called.
Can you add some dump() statements into your app?
Something like:
dump("About to create file '" + fname + "'\n");
These will show up in the adb logcat output. I'd like to see one just before
calling addNamed and one just after addNamed. At least then we'll know its
being called.
Wrapping the whole thing up in a try/catch block may help to expose errors as
well.
I tried on my unagi and in the emulator. If possible, can you send me your
entire app?
Dave Hylands
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g