Register a class in a persistent storage?

I have a class with many defined configuration variables. These are defined during execution. Is it possible to back up and recover the class in a persistent storage? If so, how?

The situation you are trying to encode to is easily manipulated with permanent storage.

If you look at the works of persistent store, you basically store an object in a persistent crack, which is identified by an ID - the ID is along the value.  Anyone who knows the ID can access the object.

However, to interpret the object, they must have the exact class which was used when the object was stored.  In your case, it's easy as your two 'Applications' will actually use the same class that they are actually just different entry points into the same set of code.

This requirement for the same class to use, becomes a problem when you have two totally different applications using the same persistent ID.  In this case, both applications have to share a class library that defines the persistent object.

But back to your situation, what you're trying to work with persistent store.

To give you more feeling for her, if your application asks the persistent object, it gets a reference to an object in the flash memory.  When your GUI application did the same thing, he will get a reference to the same object.  Then they will certainly share data, and consider it both one and other updates.

Hope that clears it for you.

Tags: BlackBerry Developers

Similar Questions

  • Store the object in a persistent storage

    Hello

    I want to store the cusom object in the persistent store.here is my custom class:

    public class {UserData

    OrgName string;
    Time to string;
    String authTocken;
    Public UserData (orgName, String authTocken, String time, String)
    {
    this.orgName = orgName;
    This.Time = time;
    this.authTocken = authTocken;

    }
    public String getOrgName() {}
    return orgName;
    }
    {} public void setOrgName (String orgName)
    this.orgName = orgName;
    }
    public String getTime() {}
    back in time;
    }
    {} public void setTime (string time)
    This.Time = time;
    }
    public String getAuthTocken() {}
    Return authTocken;
    }
    {} public void setAuthTocken (String authTocken)
    this.authTocken = authTocken;
    }

    }

    and I use the following class of persistent storage to store the data.

    / public final class PersistentStoreContents implements {Persistable
    private CAMailMinderHashTable mElements = null;
    static private instance of PersistentStoreContents = null;
    Private static final long KEY = 0x67c5b66a2bcd1dfcL;
    private PersistentObject persistentObject = null;

    /**
    * Gets the single instance of the database.
    *
    * only @return of the database instance
    */
    public static getInstance() {} PersistentStoreContents
    try {}
    If (instance == null) {}
    Logger.out ("PersistentStoreInfo", "creation of the storage object");
    instance = new PersistentStoreContents();
    }
    } catch (Exception e) {}
    instance = null;
    }
    return instance;
    }

    private PersistentStoreContents() {}
    persistentObject = PersistentStore.getPersistentObject (KEY);
    synchronized (persistentObject) {}
    If (persistentObject.getContents () == null) {}
    persistentObject.setContents (new CAMailMinderHashTable());
    persistentObject.commit ();
    }
    }

    mElements = persistentObject.getContents ((CAMailMinderHashTable));
    If (mElements == null) {}
    Logger.out ("PersistentStoreInfo", "*" + (mElements is nothing));
    mElements = new CAMailMinderHashTable();
    }

    }

    public String getElement (String key) {}
    Logger.out ("PersistentStoreInfo", "getElement:" + key);
    Return (String) mElements.get (key);
    }

    ' Public Sub setElement (String key, String value) {}
    Logger.out ("PersistentStoreInfo", "setElement:" + key + value);
    mElements.put (key, value);
    persistentObject.setContents (mElements);
    persistentObject.commit ();
    }

    UserData public getElement2 (String key) {}
    Logger.out ("PersistentStoreInfo", "getElement:" + key);
    Return mElements.get (key) (UserData);
    }

    public void setElement2 (String key, UserData userData) {}
    Logger.out ("PersistentStoreInfo", "setElement:" + key);
    mElements.put (key, userData);
    Logger.out ("PersistentStoreInfo", "added");
    persistentObject.setContents (mElements);
    Logger.out ("PersistentStoreInfo", "game content");
    persistentObject.commit ();
    Logger.out ("PersistentStoreInfo", "Validate");
    }

    Public list getAllKeys() {}
    Logger.out ("PersistentStoreInfo", "getElement:" + key);
    Return mElements.keys ();
    }
    }

    I use the follwinng code to insert data :

    PersistentStoreContents ch = PersistentStoreContents.getInstance ();
    UserData = us new UserData("gmail.com","1111","aaaa");
    ps.setElement2 ("[email protected]", US);

    But it is not inserting data in the persistent store. App is struck to the persistent store setContent method... any idea on this?

    the object you put in the store has implemented persistable, not your utility class.

  • Persistent storage problem

    Hi all

    I use a persistent storage to store my data.

    Question: Persistent data are automatically get updated while recovery of persistence data and store it in a variable local object and then modify this local variable, observe that the persistent data are also changed without saving my new changes.

    I'm storage array of user defined class in persistent for example myclass [];

    I used to store vector which has been also get updated so I have changes to my class, I'm storage table because I store the list of objects of 'MyClass '. By changing the vector in [myclass] problem has been solved, but now I'm getting same result once again.

    I create a listener in the background that will read persistent data and send only data used to my application in the foreground, but when I do some changes in my local object again once it finds that the data gets reflected in persistent.

    Please let me know what I am doing wrong. I created a library of my persistent classes so that the foreground and background the two application could access.

    Looks like my storage

    Class Myclass implements persistable

    {

    certain types of data from premitive

    MyClass2 [] arrayOfSecondClass;

    }

    class Myclass2 implements persistable

    {

    certain types of data from premitive

    Myclass3 [] arrayOfThirdClass;

    }

    class Myclass3 implements {persistable

    Some data from premitive

    }

    //////////////////////////////////////////////////////////////

    call persistent to save and retrieve data:

    Thank you Peter and James,.

    It's corrected now. Your example simple singleton helped to understand the major concept.

    Kind regards

    Aparna Bloe

  • Use a persistent storage or other methods to synchronize

    I have a user interface class that communicates with a background class by sending commands with world events to the base class. Two of them also uses a persistent storage.

    A simple method to retrieve return values could be to use a persistent as this storage:

    The user interface does:

    1 clears the back entrance in a persistent storage

    2 send the world event.

    3. going in a loop with a Thread.sleep and check if the back entrance is always empty

    After a number of loops decides that no response will be provided.

    The background task does:

    1 housing starts by accessing persistent storage in order to block with synchronization

    2 performs at the request of action

    3 put the result in the return of persistent storage field

    4 out of sync

    It sorts of handset return results and waiting for results. If the background task is not there the user interface will break out of the loop with a blank back. The only uncontrolled situation would be if the background task fails

    along the way, but then I have other problems. I threw an eye to wait/notify, semaphores and others, but the easiest solution is to use a persistent storage, because it has been used in any case for return information.

    Or expertise in this forum suggest another approach?

    A single Thread.yield is very good indeed, but if you put the user interface in a loop, just treatment Thread.yield () and the test for completion, instead of blocking your Thread event you will be hogging your event Thread and the operating system can get mad that too.

    As to notify the Ui that a message has been processed, Yes, the Observer Interface to do this.

  • When to use a persistent storage?

    Hi all

    I have created applications that use the persistent storage, and I created applications that use a SQLite database.  I also have applications that use both.  My question is this:

    Persistent storage should be limited to what it stores?  For example, should persistent storage serve more for purposes of storage of simple things like "font size selected user for the application" and "a hash of default language table and its code of language of the application"?  Alternatively, could also be recommended to act almost like a database, for example when a user does not have an SD card installed - in which case store you several vectors of objects and others?

    Is there a possibility of persistent storage is only not available due to limited space?  For example, if the user has a large number of other applications that use the persistent storage?

    Finally, I believe that persistent storage is only erased in the event of a battery pull, etc..  Is it also possible to delete in other ways, like a reboot?

    Thank you!

    I look at the characteristics of the data I store and the characteristics of the options (SQLite, folder on card SD or PeristentStore) and make a decision on this basis.

    The highlights for me are

    (a) the size of the data

    (b) requirement of presence

    (c) the use of the data

    (d) deletion of data

    Working through these:

    (a) size

    There is a reasonable amount of available devices, as well as more than PeristentStore.  If you have a vector of strings of 10,000, each 100 bytes long, it's always only! MB of storage.  And there are managers of low storage that you can listen to and store your use of the PersistentStore.  But there is more space on an SD card, and no chance to shake the Blackberry is that you use up too much memory (if you use PersistentStore the unit clears things like the old emails that can disrupt your users).

    (b) requirement of

    Don't forget that your users can remove the SD card and all data

    (c) the use of the data

    If the data lends itself to using an object of mode, it seems an appropriate way to store it in this form, which means that there is no "Serialization" required to make it a flat file or the conversion into a table.  But things like images, audio files and gain no advantage being stored as object.  So stick them on the SD card.

    (d) remove

    PersistentStore is deleted when the application is removed, which can be a good thing.

    In summary, there is no right answer here, use the best option for the job you have.

    With regard to your questions:

    "Is there a possibility of persistent storage is only not available due to limited space?

    Yesish, as mentioned, it is the low Storage Manager.  But to be honest, you can store megabytes of data in a table like structure in PersistentStore, and as long as you're careful, it will work fine.

    "I think that persistent storage is only erased in the event of a battery pull.

    No, it remains on a battery pull.  To clear, regular forms are to wipe the device, or remove the application that uses it.

  • store integers in a persistent storage

    Hi all - I'm being a key on this one I don't know. The SDK V5. Have a persistent storage object that contains an integer. If its creation as:

    persistentHashtable.put ("GPRSUpdate", New Integer (180)); in a few seconds

    Now have an editsettings (behind a login screen) screen which displays the value and allows it to be updated using an editfield. I am then convert the integer to a string and then add it to the ediitfield as follows:

    If (persistentHashtable.containsKey ("GPRSUpdate")) {}
    Integer gprsInt = (Integer) persistentHashtable.get ("GPRSUpdate");
    testInt int = gprsInt.intValue ();
    String testString = Integer.toString (testInt);
    editGPRSUpdateInterval.setText (testString);
    }

    so, which works very well. The problem is that I can't save a change and then log in to the screen later without the bombing with a classcastexception error application. The problem, I'm sure that resides in the code that performs the backup that is as follows:

    public void saveOptions() {}
           
    String gprsUpdated = editGPRSUpdateInterval.getText ();
    int savegprsInt = Integer.parseInt (gprsUpdated);
            
    persistentHashtable.put ("GPRSUpdate", New Integer (savegprsInt));
        
    persistentObject.commit ();

    }

    Can someone please explain tp starting it what is the problem? I don't know that its confused me again between objects and data types, but if someone could point out where I'm wrong it would be appreciated. See you soon

    Nothing wrong with this code that I can see.

    Can you tell us the line that throws the exception of cast.  What kind of object you actually have (debugger should find that).

  • initialization of a whole white in a persistent storage

    HI - can someone put me out of my misery with this toddler please. With the keys v 5 SDK. All I want to do is create an empty new integer into an object of persistent storage for use at a later date (like creating a string empty). If this code does not work, but I don't know how to get around:

    persistentHashtable.put ("Test", New Integer());

    error message says integer (int) in java.lang.Integer cannot apply to (), so presumably you can't initalise it without specifying a value. I want not initialized with the value 0 because it is a value - all that I want is an empty integer. Quotes does not work, does not have null - help pls?

    There is no value 'undefined' for the entire object as you found it.

    The two options that come immediately to mind are:

    (a) create an extended integer that supports a parameter "blank".

    (b) use null to indicate this.

    (b) means not having a value in the hash table - so no value indicates an empty integer.

  • Workaround for storing persistent objects I have persistent storage?

    I am storing configuration of sorts data in the persistent storage XML definitions and other data of type string.

    These data are read from a server when the application is installed and can also be requested by the user.

    It is stored in a hash table for the simple extraction and hash tables are saved in persistent storage, works well.

    Except for storing images that come in the format of png og files are not persistables. Who discovered the way lasts :-)

    Is there a way around this problem? All this data is delivered in a zip file from the server and everything is unpacked on the SD card. So is it possible to "turn" or "wrap" these png files so they can be stored in a persistent storage? Save them on the SD card are ok for temporary storage, but for 'permanent' storage, I like to keep in a persistent storage.

    arrays of bytes must be persistent.
    You can use http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/system/EncodedImage.html#getDa... to get bytes from an image, and you have already mentioned how to get it back.

    store in sqllite work similar.

  • Preference shared or persistent storage on BB10

    Hello

    I want to store some information about the phone's memory. Is a persistent storage or shared present on the BB10 preferably?

    Hello

    Yes.  You can use QSettings. For more details, see example StarshipSettings.

    https://developer.BlackBerry.com/Cascades/sampleapps/

  • Local persistent storage takes a long time

    Hi all

    I created an application in which I store locally 1,200 objects (employee information) using the persistent storage of BB model.  For each object store, I have 7 attributes: name, phone, address, email, mobile, area and position. I store this information that once (the first time, the application is launched), but this activity takes about 4 minutes to complete, I think it's a lot of time. Does make sense or I may do something wrong (not effective)? Is there another mechanism to store information on the spot which is the more efficient/FAST?

    Best regards

    Juan.

    It is normal that it takes so long, do so in a separate thread or display a progress on a splash screen bar illustrating indexing.
    If it needs to be done that only once the time needed is not very important IMO.

  • removeAllelement() method of the vector to remove persistent storage data

    Hello

    I store a vector in the persistent storage when I use removAllelement() vector method to remove all elements from the vector, this command deletes the data from the device of storage.why persistent, behaves like this. I use blackberry 8900 OS 4.6.1.

    the stored object is the same, you are currently handling. If another application is running a validation on a persistent store shops are kept and your empty vector is written in the persistent store, even without you commitment.

    You can copy the stored vector If you want to change it without changing the stored one.

  • Is it possible to edit a class that implements Persistable

    I created a custom class by implements Persistable

    help, I have created many objects and that stored in the persistent store

    Now I want to change this class by adding other variables members and methods

    is it affects our objects in the persistent store?

    Methods perform no compatibility.

  • Update of persistent storage and application

    Hi all

    is there a way to keep the persistent storage when I update the application on the device/Simulator? At the present time, I have to remove my storage before persistent that I have send a *.cod on the device/Simulator update, otherwise I get the javaloader message that the module is still in use.

    Kind regards

    Carsten

    Yes, and it works. I guess the behavior of everything that I experience is according to the design, in fact, that it makes sense, I have to admit.

    Conclusion:

    Without a persistent store, you can load and delete modules as you want without reinitialization.

    With a store persistent activity the reference must be resolved in a controlled manner, allowing RIM only via a reset after downloading the updated application. Delivery to zero then correctly replaced the old app of the new application and allows access to the preserved persistent store.

    I hope that my conclusions are correct. However, it is inconvenient because the sim card reset takes quite a long time...

    Thanks for your time, LWG!

    Kind regards

    Carsten

  • Error in persistent storage when the application update that happened.

    I've been struggling with the problem for a long time.

    MY application uses a persistent storage to store parameter information.

    But when I update my application from version 1 to version 2, number of items in my configuration page has been changed, which means the new version of the page layout will load and save some new stuff in a persistent storage that did not exist in the old persistent storage.

    Problem occurs when custorms update their request. How can we drag all the old stored information when users start to use the updated application?

    I see these three options:

    (a) the best thing to do is to delete the old application, which will get rid of the old persistent data.

    (b) create a 'version2' of you persisted object with a different name.  In your treatment of startup, you see if there is a version 1 object, and if so, migrate the setting of the object Version in 1 to your new object.

    (c) try to your compatible changes.  There are different ways to do this.  A way that is easy to understand is to persist a string, which is your options encode in XML format.  If you use an XML string, then you can add a new attribute to your new options - but the persistent object remains the same.

    I hope this helps.

  • ESXi host has no persistent storage / fsUUID is null

    Hello

    The issue I'm having involves a HP N40L Microserver w / local storage on a HP SmartArray P410 controller.  6 hard drives configured in a RAID10 array and the multitude of ESXi what OS runs on local USB.

    A recent issue w / the matrix raid caused a crash of the VMS resident and now "host ESXi has no persistent storage" message.

    I solved the problems of disk HARD w / table (replaced a disk), and the table is presented in the peripheral topic under "HP Serial Attached SCSIDisk.  ID is naa.600508b1001c8d82bf5f4a33f0e2bc04

    However, the data store does not appear in the tab of data warehouses.  I refreshed and restarted several times w / no success.

    This data store was run on an installation 5.1 ESXi (ISO custom HP) for a few years without problem.

    To try to solve the problem, I installed ESXi 6.0 U1 on a new USB stick which fortunately is now running in the Microserver but presenting the same behavior for the data store.

    Output of list of file system of storage of esxcli-

    Mount point Name of volume UUID Type of mounting Size Free

    -------------------------------------------------  -----------  -----------------------------------  -------  ----  ---------  ---------

    / vmfs/volumes/56b8f1c5-732f51cf-68ec-a0b3cce4eb3a 56b8f1c5-732f51cf-68ec-a0b3cce4eb3a 299712512 88342528 true VFAT
    / vmfs/volumes/bd8588e2 - 04362b 85 - E425 - db3beeb1519c bd8588e2 - 04362b 85 - e425 - db3beeb1519c 261853184 261844992 true VFAT
    / vmfs/volumes/fd2695e7 - 253111b 8 - b8f2 - 4a0b47e4542e fd2695e7 - 253111b 8 - b8f2 - 4a0b47e4542e 261853184 69287936 true VFAT

    Esxcfg-scsidevs output - c-

    UID device Type of device The console device Size Multipathing PluginDisplay name
    MPX.vmhba32:C0:t0:l0 Direct access /VMFS/devices/disks/MPX.vmhba32:C0:t0:l0 Mo 15484 NMP USB Direct-access local (mpx.vmhba32:C0:T0:L0)
    NAA.600508b1001c8d82bf5f4a33f0e2bc04 Direct access 11446225MBNMP Serial Attached SCSI disk HP (naa.600508b1001c8d82bf5f4a33f0e2bc04)

    I'm trying to go back through the list of commands, I tried to get more information and at some point received a response from "fsUUID is null" when you try to search the naa identifier.

    All the input welcome, thank you.

    Please tell me what FreeNas has to do with this?
    I'd say we look closer together. If you want to - call me through Skype
    Ulli

Maybe you are looking for

  • Tecra M1 - IDE 1 error after upgrade DVD

    Hi all Can I replace my DVD-ROM DVD - RW NEC 7551 A, but M1 does not recognize. After starting, it returns IDE #1 Error message.I tried whith cd - rw Teac CD-W224E, same result. Both are good work, I've tested on another laptop. Original DVD - ROM wo

  • HP 15r110na: threat of Windows Update

    Update Windows wants to install this. Updates are available Updated the drivers of Lenovo Ltd. for QitianM2300, B2300 System Firmware 1.0.5.3. Help! It is a HP laptop!  How can I get rid of this until she decides to install and kill my laptop.

  • Size of the unit for Aspire V3 - 772G

    We just bought the object model and you want to get an SSD to install in the second Bay.  I find no plug for the reader to verify the physical size of install.  I'm looking at a Sandisk 120 GB drive and a Samsung drive and both are 2.5 "7mm approxima

  • HP Photosmart C4780: download printer driver

    The printer error showed that it would not print because another sytem is connected to the printer. Not true! but restart the printer and the laptop several times always gave the same error message. Decided to reinstall the driver software forgetting

  • My photo jitters folder and does not respond when I click on the maximize button...

    Hi, I have a problem with the MY PICTURES folder in windows 7, it opens and I can get to all my files but when I want to use the maximize on the upper right button it reduced to a very narrow waist and jitters like crazy, then MY PICTURES folder does