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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:23:55+00:00 2026-05-31T06:23:55+00:00

I am facing an issue in storing data in persistence store,i am trying to

  • 0

I am facing an issue in storing data in persistence store,i am trying to store events for different dates in persistence store but the data is getting overridden the code is :

public ListEventScreen(Vector v,String timezone) { 
    for(int i=0;i<v.size();i++){
        EventBean bean=(EventBean)v.elementAt(i);
        //a normal label in the app, just to display text, anchored left
        LabelField label = new LabelField(bean.getSummary(),LabelField.FIELD_LEFT);
        //add the label to the screen
        add(label);   
        saveUserInfo(v);
    } 
}

public void saveUserInfo(Vector vectorData){
    // static{
        store = PersistentStore.getPersistentObject( 0x1dfc10ec9447eb14L );
        synchronized(store) {
            store.setContents(vectorData); 
            store.commit();
        }
    //}
}

Please let me know what has to be changed.

  • 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-31T06:23:56+00:00Added an answer on May 31, 2026 at 6:23 am

    Every time you call store.setContents(), the current contents of the persistentStore are overwritten with the Vector you are passing in. You need to make sure you are loading the previous events that were already in the persistentStore into your Vector before then adding new events into that Vector that you are then saving.

    You are also calling saveUserInfo() on every iteration of your loop in ListEventScreen(). You should be calling it outside of the loop instead.

    I would do something like this:

    public ListEventScreen(Vector v,String timezone) { 
        Enumeration e = v.elements();;
        while (e.hasMoreElements()){
            EventBean bean = (EventBean) e.nextElement();
            //a normal label in the app, just to display text, anchored left
            LabelField label = new LabelField(bean.getSummary(),LabelField.FIELD_LEFT);
            //add the label to the screen
            add(label);   
        } 
    }
    
    public void loadUserInfo(Vector vectorData){
        // static{
            store = PersistentStore.getPersistentObject( 0x1dfc10ec9447eb14L );
            synchronized(store) {
                Vector v = (Vector) store.getContents(); 
                Enumeration e = v.elements();
                while (e.hasMoreElemens){
                    vectorData.add(e.nextElement());
                }
            }
        //}
    }
    
    public void saveUserInfo(Vector vectorData){
        // static{
            store = PersistentStore.getPersistentObject( 0x1dfc10ec9447eb14L );
            synchronized(store) {
                store.setContents(vectorData); 
                store.commit();
            }
        //}
    }
    

    .

    {
        Vector v = new Vector();
        loadUserInfo(v);
        ListEventScreen(v, ...);
        ... modify v contents as needed ...
        saveUserInfo(v);
    }
    

    If you do not mind changing the format of your persistent store contents, I would wrap the store in a singleton class instead:

    public class EventBeans extends Vector implements Persistable
    {   
        private static final long persistKey = 0x1dfc10ec9447eb14L;
    
        private static EventBeans _instance = null;
        private static PersistentObject _persist = null;
    
        static{
            _persist = PersistentStore.getPersistentObject(persistKey);
            _instance = (EventBeans) _persist.getContents();
            if (_instance == null){
                _instance = new EventBeans();
                _persist.setContents(_instance);
                _persist.commit();
            }
        }
    
        private EventBeans(){       
            super();
        }
    
        public static EventBeans getInstance(){
            return _instance;
        }
    
        public static synchronized void save(){
            _persist.commit();
        }
    }
    

    .

    {
        Vector v = EventBeans.getInstance();
        ListEventScreen(v, ...);
        ... modify v contents as needed ...
        EventBeans.save();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im facing an issue with The following: public class Person { private long id;
I am facing an issue regarding EF code first version while mapping one entity
I am facing strange issue i am getting string from database and comparing with
I'm facing I guess a basic issue, but I can't find a better way
I am facing one issue related to multithreading because of shared code. I want
I am facing an issue while trying to install the requirements for my django
I have been facing a weird issue in a piece of code. void app_ErrDesc(char
I am facing an issue in updating to core data using batch updating on
I’m facing an issue with storing the DateTime object into a datatable, it looses
I am facing an issue with the JSON structure for the data I should

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.