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

Regular Contributor
Posts: 58
Registered: ‎01-19-2011
My Device: 9800
My Carrier: vodafone
Accepted Solution

Store and open remote aspx file on device

[ Edited ]





Im developing a widget that opens a remote webfilehttp:// I need it to be available offline as well so i though i would save the html file on my SDCard.




My question is. How do I save the file with all its html and how do I open it so it opens as a webpage.




Here is a code snippet of what doesnt really work. (it opens the file stored on the sd card all right but with the text instead of the html which was in the original file





















filePath = file:///SDCard/myDataFile.html;



openFile() {

blackberry.io.file.readFile(filePath, readFile);




saveFile() {

var blob = blackberry.utils.stringToBlob('');"file saved");

blackberry.io.file.saveFile(filePath, blob);





Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Store and open remote aspx file on device

I think the problem lies in the following snippet:



var blob = blackberry.utils.stringToBlob('');"file saved");



stringToBlob does not make an HTTP request to the value that you provide it.  It turns whatever string object that is received into a Blob object.


You will need to use XmlHttpRequst to make a Web request to the given page, and then use the results of that HTTP response in the call to the stringToBlob method.


Does that make more sense?




Follow me on Twitter: @n_adam_stanley
Your app doesn't work? Use BlackBerry remote web inspector to find out why.