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
RLord321
Posts: 343
Registered: ‎02-23-2009
My Device: 8700 | 8310 | BOLD | STORM

How to Delete Persistent Store When App is Uninstalled?

Is there an automatic way to delete your persistent store once your app is uninstalled?  If not, we all could have data on the blackberry that is useless to the blackberry and it would just take up space.

 

Is there a Persistent store cleaner or something?

Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to Delete Persistent Store When App is Uninstalled?

The BlackBerry will delete any persistent store on the device that contains data specific to your application, when the application is deleted.

 

I need to define 'specific to the application',  This means a class that is defined only within the application.  So if the object you commit was just a String, then it would not be deleted.  However if it was an object that was specific to your application - for example an object called 'myConfigurationData' that contained your configuration data  - then it would be deleted.

 

The reason for this is simple, if the object is specific to your application, and your application no longer exists, then there is nothing on the device that can interpret the object, so it is no use and so can be deleted.

Please use plain text.
Developer
RLord321
Posts: 343
Registered: ‎02-23-2009
My Device: 8700 | 8310 | BOLD | STORM

Re: How to Delete Persistent Store When App is Uninstalled?

So you are saying if I store 64B of Strings (not part of a custom class of my app) for my Application and my application is deleted, that memory is wasted forever??  Do you know where is this documented?

 

Thanks

Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to Delete Persistent Store When App is Uninstalled?

"if I store 64B of Strings (not part of a custom class of my app) for my Application and my application is deleted, that memory is wasted forever" is basically correct.  Of course if someone else happened to use your persistent ID, or the user wiped the device, then the storage would be recovered.

 

"Do you know where is this documented?"

 

I suspect it is documented elsewhere, but this came to hand quickly:

 

How To - Handle stored data when removing an application
Article Number: DB-00424
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800708/800647/How_To_...

This KB article contains the following sentence:

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

 

I should have pointed straight at this initially I guess.

Please use plain text.
Developer
Ted_Hopp
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: How to Delete Persistent Store When App is Uninstalled?

It's a shame that document doesn't even mention the third way of storing data (as of device software 4.2): the file system.



Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: How to Delete Persistent Store When App is Uninstalled?

Good point, I'll have that added to the KB article.

 

Data stored using a FileConnection is not removed when an application is uninstalled.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
expo
Posts: 9
Registered: ‎11-11-2009
My Device: Not Specified

Re: How to Delete Persistent Store When App is Uninstalled?

A quick question here. If the app is updated from a older version to newer one, is the persistent store still preserved?  Thanks a lot!

Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: How to Delete Persistent Store When App is Uninstalled?

Check this thread.

 

http://supportforums.blackberry.com/t5/Java-Development/Persistent-Store-Across-Application-Upgrades...


Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
Developer
bskania
Posts: 105
Registered: ‎04-24-2012
My Device: blackberry developer
My Carrier: relience

Re: How to Delete Persistent Store When App is Uninstalled?

[ Edited ]

I gone through this thread.

I also want to achieve the same.

 

I had created one class that is storing the Questions detail and then stored in in persistent object.

But still when I delete that application I am getting back the result. Data is still not clear.

 

public class Score implements Persistable {
        private String _START_DATE_KEY = "start_date";
        private String _END_DATE_KEY = "end_date";
        private String _TOTAL_QUESTION_KEY = "total_question";
        private String _SCORE_KEY = "score";

        private long start_date, end_date;
        private int questions, score;
        private int question_id;

//* getter and setter method

 

}

 

public class MyVector extends Vector implements Persistable {

        public MyVector() {
            super();
        }
    }

 

 

public class PersistantScore implements Persistable {

    private long KEY = 0x2562651c36cbeb75L;
    private Score _score = new Score();
    private PersistentObject persist;
    private MyVector _scores_data = new MyVector();

    public PersistantScore() {
        persist = PersistentStore.getPersistentObject(KEY);
        _scores_data = (MyVector) persist.getContents();
        if (_scores_data == null) {
            // if (_scores_data.size() == 0) {
            // _score = new Score();
            // } else {
            // _score = (Score) _scores_data.lastElement();
            // }
            // } else {
            _scores_data = new MyVector();
            _score = new Score();
        }
    }

    public MyVector get_scores_data() {
        return _scores_data;
    }

    public void set_scores_data(MyVector _scores_data) {
        this._scores_data = _scores_data;
        persist.setContents(this._scores_data);
        persist.commit();
    }

    public Score get_score() {
        return _score;
    }

    public void set_score(Score _score) {
        this._score = _score;
        this._scores_data.addElement(this._score);
        persist.setContents(this._scores_data);
        persist.commit();
    }

}

 

Please let me know where I am doing mistake.

Thanks in advance.

bskania.

Please use plain text.