Will the data stored in my PersistentObject be retained on App update in Blackberry.?

StackOverflow https://stackoverflow.com/questions/11206748

  •  17-06-2021
  •  | 
  •  

سؤال

I have developed a blackberry app, in which I am using Persistent Storage to save some data. The app is already live on the market. I am creating some new PersistentStorage values in my second version. Will this data be retained if I update my app from BlackBerry App store? or the data will be lost?

هل كانت مفيدة؟

المحلول

If you change the class definition of your persistent objects (like adding, removing or changing the type of data members) then you will likely loose your data. The system will detect the change in structure and will have to delete the class definition and all instances of the class.

There are two ways around this problem:

  1. Only use classes that are defined in the OS (HashTables, Strings, int, float, double, etc) to build up the structure that you need. (this will have the side effect of the data persisting past application deletion as well);
  2. If you need to use a new class, and then need to change it, create a new class that uses a different persistent object ID and during start up detect if the user has data stored under the old class. If so, migrate the data to the new class and delete the old class.
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top