Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
confinedspace
Posts: 40
Registered: ‎04-16-2010
My Device: na
My Carrier: na

Default Path to User Directory?

My app requires data to be sotred in a XML document. I've always used the directory //store/home/user/.

 

But I believe the Tourch uses the path //Device/home/user/ - other devices (or future devices) may use different paths.

 

Is there a way to get a default path to the user directory? Or is there another directory I can use?

 

Kind regards.

Please use plain text.
Developer
csibbdev
Posts: 67
Registered: ‎09-23-2010
My Device: Curve
My Carrier: T-Mobile

Re: Default Path to User Directory?

I use //store/home/user on a torch with no problems.

Please use plain text.
Developer
confinedspace
Posts: 40
Registered: ‎04-16-2010
My Device: na
My Carrier: na

Re: Default Path to User Directory?

[ Edited ]

Not sure why I can't get it working on the simulator or physical device then. Is the //store directory on the SD card? I've also tried to use blackberry.io.dir.exists() to check if the directory exists, but I get the error message: "file system error (1003)" (I have <feature id="blackberry.io.dir" version="1.0.0"/> in my config). Not sure if I'm passing the dir through correctly: blackberry.io.dir.exists("file:///store/home/user/")? Passing through "//store/home/user" said it was missing a colon ( : ). The 'exists' function works fine on the Blackberry 9000 simulator.

 

If I browse the files on the 9800 simulator, this is what I see:

 

9800.png

Please use plain text.
Developer
csibbdev
Posts: 67
Registered: ‎09-23-2010
My Device: Curve
My Carrier: T-Mobile

Re: Default Path to User Directory?

Here is one I use with no issues.

 

"file:///store/home/user/documents/SEARCHDATA.txt"

 

Also this is not on the SD card but rather internal memory..

 

Do you have blackberry.io.file in your config.xml?

 

 

 var XMLLocation   = "file:///store/home/user/documents/SEARCHDATA.txt";
      if (blackberry.io.file.exists(XMLLocation))
        {
            blackberry.io.file.deleteFile(XMLLocation);
        }

I look for file rather than directoryu but the format may help.

 

 

That is a strange error though, you shoudl be getting a true/false back.

Please use plain text.
Developer
confinedspace
Posts: 40
Registered: ‎04-16-2010
My Device: na
My Carrier: na

Re: Default Path to User Directory?

Thanks for getting back to me again csibbdev.

 

I have been using a path like that for about 3 months out in the wild and it's been working fine. But it doesn't work for people with a Tourch.

 

I've just tried this snippet of code on the Tourch simulator (baring in mind this has worked on many devices for months):

 

 

var filePath = "file:///store/home/user/test.xml";
var xmlString = "<data>test</data>"; var parser = new DOMParser(); var doc = parser.parseFromString(xmlString, "text/xml"); try{ var blobData = blackberry.utils.documentToBlob(doc); blackberry.io.file.saveFile(filePath, blobData); }catch(e){ alert(e); }

 

 

And get the error "Argument is not nullable". I have blackberry.io.file in my config. I also tried with the path "file:///store/home/user/documents/test.xml".

 

I thought it was just my simulator that was broken but the physical device isn't working either, although I haven't tried this snippet of code yet.

Please use plain text.