Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7445445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:49:27+00:00 2026-05-29T11:49:27+00:00

I am trying to create a persistent and shared variable that will keep track

  • 0

I am trying to create a persistent and shared variable that will keep track of the number of notifications available to the user in a Blackberry app. This number is showed on the home screen and should be kept even after the device is turned off until they check the application themselves, then the number is reset. I have been using a singleton to share the variable between the background process and the UI app itself below:

import net.rim.device.api.system.RuntimeStore;

public class IconManager {
    private static IconManager _instance;
    private static final long GUID = 0xab4dd61c5d004c18L;
    private int iconCount;

    // constructor
    private IconManager() {
        iconCount = 0;
    }

    public static IconManager getInstance() {
        if (_instance == null) {
            _instance = (IconManager) RuntimeStore.getRuntimeStore().get(GUID);
            if (_instance == null) {
                IconManager singleton = new IconManager();

                RuntimeStore.getRuntimeStore().put(GUID, singleton); 
                _instance = singleton;
            }
        }
        return _instance;
    }

    public int getCount() {             
        return iconCount;
    }

    public void setCount(int count) {      
        iconCount = count;
    }
}

I have been mainly using this site to try to figure out the Persistent store portion: http://supportforums.blackberry.com/t5/Java-Development/Storing-persistent-data/ta-p/442747

Is there an alternative to implement the persistent store given the above runtimestore? I was originally thinking of using code from the Blackberry example, but I’m confused on how to do this. From another thread user mparizeau wrote the following:

persistentCount = PersistentStore.getPersistentObject(0xdec6a67096f833cL); 
synchronized (persistentCount) { 
    if (persistentCount.getContents() == null) { 
        persistentCount.setContents(new StoreInfo());
        persistentCount.commit(); 
    } 
}  
_data = (StoreInfo)persistentCount.getContents();

Now when you want to update it and save to the PersistentStore you can have something like:

_data.incElement();
synchronized(persistentCount) {
    persistentCount.setContents(_data);
    persistentCount.commit();
}

Could this be used in the above code somehow? I am extremely new to java and BB development so any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:49:28+00:00Added an answer on May 29, 2026 at 11:49 am

    I don’t think you want to use RunTimeStore, since you want to the information to persist even after the device is turned off. From this page

    The runtime store is not persistent. When you restart the BlackBerry
    device, the data in the runtime store clears.

    Try something like this:

    public class IconManager {
        private static IconManager _instance;
        private final long GUID = 0xab4dd61c5d004c18L;
        private PersistentObject store;
        private int iconCount;
    
        private IconManager() {
            store = PersistentStore.getPersistentObject(GUID);
            synchronized(store) {
                if(store.getContents() == null) {
                    store.setContents(new Integer(0));
                    store.commit();
                }
            }
            iconCount = ((Integer)store.getContents()).intValue();
        }
    
        public static IconManager getInstance() {
            if (_instance == null) {
                _instance = new IconManager();
            }
            return _instance;
        }
    
        public int getCount() {             
            return iconCount;
        }
    
        public void setCount(int count) {      
            iconCount = count;
            synchronized(store) {
                store.setContents(new Integer(iconCount));
                store.commit();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create my first iPhone app that would play back audio. When I
I am trying to create an app that has a list of users and
I am trying to create a PBBG (persistent browser based game) like that of
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create a user account in a test. But getting a Object reference
I'm trying to create a persistent SQL (SQL Server 2005) lock on a table
I am a cocoa newbie trying to create an iPhone app including Core Data.
I am trying to create a html page with persistent footers using jquery mobile.This
I'm trying to create content via a small C# desktop app, and have it
I'm trying to create a form filter, that would do some post-processing of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.