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 7171057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:20:08+00:00 2026-05-28T15:20:08+00:00

I am using persistent object in blackberry to store config details specific to the

  • 0

I am using persistent object in blackberry to store config details specific to the app. Here is how I am implementing the class

public class Preferences implements Persistable
{
    private static  PersistentObject persistentObject = PersistentStore.getPersistentObject(0x2759d6ff72264bdbL);
    private static Hashtable tbl = new Hashtable();

    public static void storeLoginToken(String token)
    {
        token = removeCharAt(token,0);
        token = removeCharAt(token,token.length()-1);
        tbl.put("token", token);
        persistentObject.setContents(tbl);
        persistentObject.commit();
    }

    public static String getLoginToken()
    {
        Hashtable tbl = (Hashtable)persistentObject.getContents();
        try
        {
            String token = tbl.get("token").toString();
            System.out.println("Token = "+token);
            return token;
        }
        catch(Exception e)
        {
            return null;
        }

    }
}

But if I uninstall/delete the app these stored values are not getting deleted. When I installs the app for next time the app is fetching the old stored values.

How can i do this properly in blackberry?
Thanks

  • 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-28T15:20:09+00:00Added an answer on May 28, 2026 at 3:20 pm

    Create a custom hashtable class like this

    package com.myapp.items;
    
    
    import net.rim.device.api.util.Persistable;
    
    import java.util.*;
    
    public class MyAppHashtable extends Hashtable implements Persistable{
    
    }  
    

    And change your code to

    public class Preferences
    {
        private static  PersistentObject persistentObject = PersistentStore.getPersistentObject(0x2759d6ff72264bdbL);
        private static MyAppHashtable tbl = new MyAppHashtable ();
    
        public static void storeLoginToken(String token)
        {
            token = removeCharAt(token,0);
            token = removeCharAt(token,token.length()-1);
            tbl.put("token", token);
            persistentObject.setContents(tbl);
            persistentObject.commit();
        }
    
        public static String getLoginToken()
        {
            MyAppHashtable tbl = (MyAppHashtable )persistentObject.getContents();
            try
            {
                String token = tbl.get("token").toString();
                System.out.println("Token = "+token);
                return token;
            }
            catch(Exception e)
            {
                return null;
            }
    
        }
    }
    

    This is so that we adhere to the following info from RIM

    The BlackBerry persistence model

    When you use the BlackBerry persistence model, data is only deleted if the store contains data that belongs to the removed application.

    For example, if an application stores an object with a package called com.mycompany.application.storage and no other application on the BlackBerry smartphone makes reference to the package, the persistent store and the removed application are deleted.

    The same is true if the object is wrapped in a container such as a Vector. Even if only one of the elements of the Vector has a package name that is not used by other applications, the entire Vector is removed from the persistent store.

    Note: If the application does not store any objects with an identifying package structure, (for example, an application that stores java.util.Vector or javax.microedition.location.AddressInfo objects), the application should create and use a class that extends Vector in order to identify that Vector belongs to the given application. When you store this Vector, which is identified uniquely by its package, you guarantee that the data is removed from the persistent store when the application is removed.

    This info is from here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the SQLite database and have the following persistent class (simplified): public
I am using persistent stores to store data in a Blackberry application. While I
I'm using app engine datastore so I have entity like this. @PersistenceCapable public class
I'm using a cache with disk store persistence. On subsequent reruns of the app
FastObjects.NET Saves the whole class object(if marked with attribute Persistent ) at once in
I have a persistent hibernate object I obtained using session.save(object) I changed it since.
I am creating multiple persistent store in my application, but I am using only
I'm writing a small application using GWT and JDOs to store persistent data. I've
I'm using Core Data to save a persistent store in the document directory of
For my web app security I'm using FormsAuthentication / MembershipProvider with a non persistant

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.