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

Posts: 66
Registered: ‎09-14-2011
My Device: Simulator
My Carrier: Developer
Accepted Solution

Transfer data between two pages

[ Edited ]

I have a login page where I'll give login and password , upon successful login I'll be recieving a LoginToken from the server which i have to use it to obtain the information of that particular user in next page(profile page).

My problem is I recieve the LoginToken when i login in the login page but how can i pass that LoginToken to the next page?

I thought of creating a file and writing the token in that file and in profile page i'll again read that file and send the LoginToken to server and server will give me xml file of that profile in return.

Is there any other way to retain the information and send it to next html page????

And I do like to know how to create a file and write data into it.


PS: I looked at the File API


but there is nothing mentioned there about writing into file.

Posts: 817
Registered: ‎11-19-2009
My Device: Z10, Q10, 9900, 9790, PlayBook,
My Carrier: T-Mobile UK, Three, O2, Orange, Sunrise, Swisscom

Re: Transfer data between two pages

[ Edited ]

Assuming we're talking about virtual pages (using Javascript), you just need to store the variable in a Javascript object. If you need to store it long-term, then you'd simply use LocalStorage which is not specific to the BlackBerry platform.

Olivier - interfaSys ltd
Developing for BlackBerry 10 devices using the Sencha Touch framework.
Regular Contributor
Posts: 58
Registered: ‎01-19-2011
My Device: 9800
My Carrier: vodafone

Re: Transfer data between two pages

[ Edited ]

Local storage does not work on OS5.


I think the right way to do it is via webkit / gears browser db.


The only reason I see you would use filesystem is if you need data to be shared between applications (browser database does not support that). Anywayz, you can use this to store data on you sdcard


var filePath = file:///SDCard/myData.txt;


function saveFile(content) {

    try {

        //check to see if the file exists.  Exception will be thrown if the path is to a existing file

        if (blackberry.io.file.exists(filePath)) {

            //if the file exists, you have to delete the existing one before saving the new copy



        var blob = blackberry.utils.stringToBlob(content, "UTF-8");

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



    catch (e) {

        alert('savefile error ' + e.message);




Posts: 66
Registered: ‎09-14-2011
My Device: Simulator
My Carrier: Developer

Re: Transfer data between two pages

I cannot javascript object because once the page is closed and another page opened the javascript object will be destroyed so i cannot get anything.

I have a login page where I login and I'll get the loginToken upon successful login

and then profile page will open i need the loginToken which i recieved in the login page to get the profile information in profile page.

And no i dotn want it in persistent storage the moment user closes the pplicatin it should be removed from memory.

I dont this is acceptable solution but i did one thing.


I appened the LoginToken to the URL of the next page like this when i recieve the LoginToken


This is in login page when i recieve the logintoken (just the way method post works):

window.location = "roster.html?loginToken="+xmlDoc.getElementsByTagName("LoginToken")[0].childNodes[0].nodeValue;


And in roster.html page i'm using this java script to split the URL and get the what ever values I appended. (found this function on internet sorry i forgot where i copied it from so cant give credits Smiley Sad )

function getParams() {
    var idx = window.location.search.indexOf('?');
    var params = new Array();
    if (idx != -1) {
        var pairs = window.location.search.substring(idx+1, window.location.search.length).split('&');
        for (var i=0; i<pairs.length; i++) {
            nameVal = pairs[i].split('=');
            params[nameVal[0]] = nameVal[1];
    return params;


And i used this function to parse the URL and get the loginToken which i appended in the login.html page


params = getParams();
var loginToken = unescape(params["loginToken"]);

 It is sloved.


What I'm wondering is that is the method I used here is reliable or not???

If i deploy it to the app store then woud it work on every os version???

Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Transfer data between two pages

You could always store small bits of information the traditional way through cookies.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Posts: 66
Registered: ‎09-14-2011
My Device: Simulator
My Carrier: Developer

Re: Transfer data between two pages


I never got that idea of using cookies

It worked like miracle

Thanks for the advice