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
Trusted Contributor
Posts: 158
Registered: ‎03-09-2010
My Device: 8900
My Carrier: developer

how i run my application for a limited numbers of times

Greetings

 

hi

 

please help me in finding the way of running the app for limited number of times .

 

how could i do that ?

 

please help

 

Regards

Amrinder singh

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: how I run my application for a limited numbers of times

[ Edited ]

Does your application contact a Server, or is it standalone?

Trusted Contributor
Posts: 158
Registered: ‎03-09-2010
My Device: 8900
My Carrier: developer

Re: how I run my application for a limited numbers of times

hi

 

 

 

Application is not in the server contact ,it is standalone .

 

regards

Amrinder singh

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: how I run my application for a limited numbers of times

In that case, you have to put something in a hidden but persisted place on the BlackBerry, that is not removed when your application is removed.  So the easiest thing is to choose a persistent storage GUID, and persist an Integer into it.  Check and increment the value each time it is used (and persist the updated value  of course).

 

There is a fair amount of sample code that talks about how to use Persistent Storage in the documentation, so if you don't know persistent store yet, I'm sure you can figure it out. 

Trusted Contributor
Posts: 158
Registered: ‎03-09-2010
My Device: 8900
My Carrier: developer

Re: how I run my application for a limited numbers of times

hi peter sir

 

 

i had done the persisitent store in my app .

class InstallDemo extends MainScreen
{
    private static PersistentObject flagstore;
    static 
    {
        flagstore = PersistentStore.getPersistentObject(0xa12592786392511L); 
    }
    InstallDemo()
    {
        if(flagstore.getContents()== null)
        {
            setTitle("My Application");
            add(new RichTextField("WelCome To My Application!"));
            flagstore.setContents("true"); 
        }

        else
        {
//            doing something 
            		       
        }
    }

Now ,this help in storing the value .

This persisitent Object is doing that,First time when the App running ,then

 

WelCome To My Application! is coming on the screen .

 

Second time ,when i run my application ,then else condition will run every time .It happens Because ,it store the value as persistent store of long key .

 

I able to store the value of keys in bb   .

 

"So the easiest thing is to choose a persistent storage GUID, and persist an Integer into it.  Check and increment the value each time it is used (and persist the updated value  of course)."

 

How should i persist an integer in it  ans increment the valued in it for running the app for limited numbers of time .

 

 

Regards

Amrinder singh

 

 

 

Developer
Posts: 516
Registered: ‎07-23-2010
My Device: 9900

Re: how I run my application for a limited numbers of times

You are storing a String in the Persistent Store. As recommended by Peter use the Integer class and increment that number when you need to.