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

Java Development

Reply
Developer
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Problem in persistent value

Hey

I have created an application . When my application starts first time, SplashScreen gets open and after that Main screen, if i comes out of the application and starts the application agains i directly moved to MainScreen.

And i am doing like this..

In SplashScreen i am doing like this:.:

 

 

PersistentObject object = PersistentStore.getPersistentObject(screenKey);
System.out.println("Content is : "+object.getContents());


boolean flag1 = ((Boolean) object.getContents()).booleanValue();
System.out.println("Flag value is : "+flag1);
if(flag1==true)
{
System.out.println("If value is true..Then move to SlidingScreen!!");

}
else
{
System.out.println("If value is flase..Then move to OMainScreen!");

}

}

}

 

 

Its working fine.

 

But if i run the application again, then i directly moved to the Mainscreen.

Why?

 

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Problem in persistent value

Where do you modify the persistent object?
It may be good to check for its existance as well.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in persistent value

In my mainMethod class i check the value.

 

 

PersistentObject object = PersistentStore.getPersistentObject(screenKey);
System.out.println("Value od object is : "+object.getContents());
if(object.getContents()==null)
{
boolean flag= true;
PersistentObject flagObject;
flagObject=PersistentStore.getPersistentObject(screenKey);
flagObject.setContents(new Boolean(flag));
flagObject.commit();
System.out.println("Value is : "+flag);
}

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Problem in persistent value

there is a bit of redundant code, but otherwise it looks fine.
you could re-use the persistent object, and use Boolean.TRUE, but the value should be set correctly.

To test read the value after commit, use the same code as in your startup part.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in persistent value

Is it possible that boolean retains its vaule in Persistent. 

 

It always give the same value and thats y even if i run my application again, instead if moving to the splashscreen i am direct;y going to the mainscreen? 

Developer
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in persistent value

Hey

i have changed the key vlaue and run the code. First time i am getting the correct value and after that if i run my app again , the value remains same.

 

Any reply???

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Problem in persistent value

how did you create the key?
i suggest your package name plus something unique, then using string to long in eclipse.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in persistent value

I mean i have changed the key value.

 

But still i am not getting the output.??

 

i have changed the value if flag as false nw if i run my application again the value of flag must not be false. But its showing false.

Developer
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900
My Carrier: developer

Re: Problem in persistent value

Hey

 

Anyone please help me to resolve this issue???

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Problem in persistent value

if you could bother to answer my questions i could continue to try, otherwise not so much.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter