PersistentObject and signerId

If you look at the documentation of the API for net.rim.device.api.system.PersistentObject, you will see an example like this:

    long MY_DATA_ID = 0x33abf322367f9018L;
    Hashtable myHashtable = new Hashtable();

    PersistentObject persistentObject = PersistentStore.getPersistentObject( MY_DATA_ID );

Whence this long signerId?  You just do it and hope that nobody takes the same value?  Is it supposed to represent a company, a single application, or a coherent piece of persistent data, in this application?  The javadoc for the methods that take the signerId as a parameter doesn't say a lot.  Any clarification would be greatly appreciated.

You can create a string that is unique to your application and create a hash value.

For example:

com.mycompany.MyApp.Data

If you use the JDE, you can select a channel like this in the editor, open the context menu and select "convert long."

Tags: BlackBerry Developers

Similar Questions

  • PersistentObject and problem SendListener

    I recorded a SendListener in order to intercept outgoing e-mail. When my manager is called I want to access my application stored in PersistentObject settings to determine what I should do in my manager of sendMessage.

    The problem is that I can't access any information contained in my application. I suspect that it is because my manager sendMessage runs in the context of the mail application.

    Should which design I follow to access my store persistent since a manager like this?

    Thank you

    John.

    I must admit, I have not really tested recently myself, but as far as I know, you should be able to access your persistent objects - assuming that you are running by using your own code and persistent objects classes, the framework should not matter.

    Can you describe the problem when you try to access the information?  If your objects seem to be "null" then I guess you use static references.  static variables are specific to a context, then your listener will see different static variables for your application.

    The reason why I've not tested this recently is that the normal practice for Auditors is change in context of your Application, and the usual approach is via a GlobalEvent

    http://supportforums.BlackBerry.com/T5/Java-development/global-events-and-global-event-listeners/TA-...

  • Refresh ListField and store multiple entries

    I'm having a problem trying to get my program to save the information. I recently ended show him an entry but I don't think that im doing something because it shows just the same entry over and over again.

    Im trying to to save all fees in the form of spending and then display them in the WelcomeScreen listbox. I'll include the store file, welcomeScreen and booking fees.

    What would be the best way to store this information and display them in the listfield? Also when you return to the WelcomeScreen how can I have the update so the listfield is updated?

    WelcomeScreen:

    package moneyMasterApp;
    
    import java.util.Vector;
    
    import net.rim.device.api.system.*;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.ui.decor.*;
    
    public class WelcomeScreen extends UiApplication implements StoreResource {
        //Declare Variables
        //create a button here with the text 'Submit!'
            //ButtonField.CONSUME_CLICK will prevent the Menu from showing up when the user clicks the button.
            ButtonField btnDeposit = new ButtonField("Deposit", Field.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
            ButtonField btnExpense = new ButtonField("Expense", Field.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
            UiApplication nxtscreen = UiApplication.getUiApplication();
            HorizontalFieldManager _FieldManagerTop;
            LabelField myTitleLabel;
            BitmapField bitpam = new BitmapField();
            Background bg;
            LabelField label = new LabelField("Please Select Action:");
            FieldListener listener = new FieldListener();
            private static Vector _data;
            private static PersistentObject store;
            private ListField ExpenseList = new ListField();
    
        public static void main(String[] arg) {
            WelcomeScreen app = new WelcomeScreen();
            app.enterEventDispatcher();
        }
    
        public WelcomeScreen() {
            MainScreen mainScreen = new MoneyMakerMainScreen();
            //Set the title of the screen
            mainScreen.setTitle("MoneyMaster");
            //Add labels and other items
            _FieldManagerTop = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);
            myTitleLabel = new LabelField("MoneyMaster");
            bitpam = new BitmapField();
            bitpam.setBitmap(Bitmap.getBitmapResource("bbicon.png"));
            _FieldManagerTop.add(myTitleLabel);
            _FieldManagerTop.add(bitpam);
            bg = BackgroundFactory.createLinearGradientBackground(0x2ebaeb, 0x2ebaeb, 0x7cbaed, 0x7cbaed);
            mainScreen.getMainManager().setBackground(bg);
    
            synchronized(store) {
                Vector _data = (Vector) store.getContents();
                int count = _data.size();
                ExpenseList.setEmptyString("Nothing", DrawStyle.LEFT);
                ExpenseList.setSize(count);
            }
    
            ExpenseList.setCallback(new ExpenseListCallback());
    
            //Add objects to screen
            mainScreen.add(_FieldManagerTop);
            mainScreen.add(label);
            mainScreen.add(new SeparatorField());
            btnDeposit.setChangeListener(listener);
            btnExpense.setChangeListener(listener);
            mainScreen.add(btnDeposit);
            mainScreen.add(btnExpense);
            mainScreen.add(new SeparatorField());
            mainScreen.add(ExpenseList);
            pushScreen(mainScreen);
    
        }
    
        static {
            //Retrieve a reference to a persistent object
            //and set its contents to a new new vector if it is empty
            store = PersistentStore.getPersistentObject(0xe69c43e620187619L);
            //Hash of: "TechStormSolutions.MoneyMaster.Application"
            synchronized(store) {
                if (store.getContents() == null) {
                    store.setContents(new Vector());
                    store.commit();
                }
            }
            //retrieve the contents of the PersistentObject
            //and store in a Vector
            _data = new Vector();
            _data = (Vector)store.getContents();
        }
    
        private final class MoneyMakerMainScreen extends MainScreen {
            protected void makeMenu (Menu menu, int instance) {
                menu.add(deposit);
                menu.add(expense);
                super.makeMenu(menu, instance);
            }
    
            public void close() {
                Dialog.alert("Closing Application");
                super.close();
            }
        }
    
        private MenuItem deposit = new MenuItem("Deposit", 1, 100) {
            public void run() {
                UiApplication.getUiApplication().pushScreen(new depositForm());
            }
        };
        private MenuItem expense = new MenuItem("Expense", 2, 101) {
            public void run() {
                UiApplication.getUiApplication().pushScreen(new expenseForm());
            }
        };
    
        class FieldListener implements FieldChangeListener {
    
            public void fieldChanged(Field f, int context) {
                //if the deposit button is clicked
                if (f==btnDeposit) {
                    UiApplication.getUiApplication().pushScreen(new depositForm());
                };
                if (f==btnExpense) {
                    UiApplication.getUiApplication().pushScreen(new expenseForm());
                }
            }
    
        }
    
        final class ExpenseListCallback implements ListFieldCallback {
    
            public void drawListRow(ListField list, Graphics g,
                    int index, int y, int w) {
                int count = _data.size();
    
                synchronized(store) {
                    Vector _data = (Vector) store.getContents();
                    if (!_data.isEmpty()) {
                        String[] ExpList = new String[count];
                        for (int i = 0; i < count; ++i) {
                            StoreInitial info = (StoreInitial) _data.elementAt(i);
                            ExpList[i] = info.getElement(StoreInitial.AMOUNT);
                        }
    
                        g.drawText(ExpList[0], 0,y,0,w);
                    }
                }
    
            }
    
            public Object get(ListField listField, int index) {
                return null;
            }
    
            public int getPreferredWidth(ListField listField) {
                return Display.getWidth();
            }
    
            public int indexOfList(ListField listField, String prefix, int start) {
                return listField.indexOfList(prefix, start);
            }
    
        }
    }
    

    In my listcallback I had to change that loop and out so that the index was the counter.

    synchronized(store) {
                    Vector _data = (Vector) store.getContents();
                    if (!_data.isEmpty()) {
                        String[] ExpList = new String[index];
                        StoreInitial info = (StoreInitial) _data.elementAt(i);
                        g.drawText(info.getElement(StoreInitial.AMOUNT), 0,y,DrawStyle.RIGHT,w);
                    }
                }
    
  • Best way to approach persistence

    Hello, all the

    I'm playing with the persistence of data on th BB (4.2 +) API and have a general question about the best/recommended way to use, performance among these two options for the scenario:

    SCENARIO: My application handles about 4 entities ("models", if you want to MVC-talk) information.

    Option 1: Create a class for each model (vector extension) with a PersistentObject and keyfor each.

    Option 2: Create a unique Hashtable or a vector, which will be a single instance of PersistenObject, and there are 4 references to the models/entities.

    Maybe that's not a big deal, but I would like to know which of these two approaches is preferable. Or is there a third?

    What happens if the scenario includes models more and more thousands of entries each?

    Thank you!

    A number of things.

    (1) I think that this comment of Plato is incorrect:

    "all calls to hash.put () will automatically continue the news data - there is no need for calls following to.commit ().

    It is my understanding, that because the object is shared, it seems that this happens, but in fact, except if you make a commit, you cannot be 100% sure that the data has been written to Flash.  However, when a commit is made, treatment will commit all the missing data, so data could be brought through the validation of another application (and vice versa).

    (2) to respond to this comment:

    "If she does go all references each time? Or it it keeps a list of objects 'uncommitted '? "

    My understanding and experience suggests that only the uncommitted objects are validated.  For example, I tested with a vector containing a large number of items.  If I update an element, and then validate the operation, validation is extremely fast.  If I update a lot, and then engages, the validation takes more time.

    One last point, I agree with Simon, I'd go with a hash table or a single vector.  Another consideration is synchronization, you can break it up to make sync easier, if you have multiple Threads that need to synchronize on different parts of this one object.

  • store the byte [] in the preferences?

    I have several pieces of data that I have successfully store Prefs (PersistentObject and Hashtable). Currently, I am only store strings and integers (which I converted to strings). I want to start storing the encrypted data (byte []) in the preferences. What is the best way to implement? I paint a white on research and I want to ensure my implementation is not that work today, but it fails two months later.

    Thanks in advance!

    Byte array is persistent, as is.  Can you not just add it as an entry in your hash table?

  • Cod signed fails on the device with the attempts to access a secure API

    Feature: "BOLD"

    JDE: Eclipse (3.4.1) plugin (1.0.0.67) w/component pack 4.6.0.19

    JDK: 1.5

    Last week, I built and signed myApp. It loaded and run correctly on the device. This week changes have been made to the code, recompiled, signed and redeployed. Now, we get the attempts to reach an eveytime failure secure API that the code is executed. The secure API is PersistentObject and was last week.

    My last attempt, I deleted physically files .alx and .cod, .jar, .jad, .csl, .cso files prior to construction. I have verfied the 352 KB .cod size after compilation and 356 Ko after the signing. All of the code in the signature tool reflects signed. I even removed the .cod from the server where it is deployed and verified that everything is signed. We use the loader of office right now to load the code on the phone.

    EventLog

    S Java Exception - RuntimeException

    | Error at startup myApp:Module "myMod" trying to access a secure API.

    a system - error myApp:Module "myMod" from trying to access a secure API.

    a system - the linker error: "VerifyError" for myApp

    a system - Module 'myMod' attempts to access a secure API.

    a system - module 6803 cannot refer to net.rim.device.api.system.PersistentObject

    a system - VM:LINK myApp

    a system - CMM: myApp (6803) No sig 0 x 33

    a system - the linker error: "VerifyError" for myApp

    a system - Module 'myMod' attempts to access a secure API.

    a system - module 6803 cannot refer to net.rim.device.api.system.PersistentObject

    a system - CMM: myApp (6803) No sig 0 x 545252

    a system - VM:LINK myApp

    I never saw this when the cod file has actually been signed.  You can try to use javaloader to get cod off the coast of the unit and compare it with your signature.  Just a thought.

  • Listener key problem?

    Hello. I have an application which used many listeners as PhoneListener, FolderListeners, SMSListener, PersistentObject and KeyListener. The problem is that keylistener detect only 2 keys on the Green and Red ke, another looks like they are locked, but why, I'm building a new listener class as keys:

    public class kl implements KeyListener
    {
    public boolean keyChar (key char, int status, int time)
    {
    LogThis ("keyChar: >" "+ key +")< status:"="" +="">
               
    Returns false;
    }
           
    public boolean keyDown (keycode, int, int times)
    {
    LogThis ("openmic keycode_Down->" + keycode);
                
    int iKey = Keypad.key (keycode);
                
    LogThis (' keyDown openmic-> "+ iKey ');
    Returns false;
    }
            
    public boolean keyUp (keycode int, int times)
    {
    LogThis (' keyUp openmic-> "+ keycode");
    Returns false;
    }
            
    public boolean keyStatus (keycode int, int times)
    {
    Returns false;
    }
            
    public boolean keyRepeat (keycode int, int times)
    {
    LogThis ("openmic keyRepeat->" + keycode);
    Returns false;
    }
    }

    In the constructor of the class, I call this clas as: addKeyListener (new kl());

    But it works only for keys shown above why it does not work for all keys?

    Thank you in advance.

    Large.

    You can do this mark as resolved then?

  • I need a few persistent data store help of Pentecost

    Hi, I have a problem, try to store persistent data, I m using Eclipse 3.4.2 and BlackBerry plugin, as I check my work with the correct laboratory and my code hasn´t issues only a warning I see on the laboratory code it s normal, but when I try to run the Simulator I get this:

    "Eception exception: lack of measurement of the resource.

    and this is the code

    package com.rim.someguy;
    
    //Import section
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.system.*;
    import net.rim.device.api.util.*;
    import net.rim.device.api.i18n.ResourceBundle;
    import java.util.*;
    
    public class measure extends UiApplication implements measureResource{
    
        //Variables for user interface fields
        private EditField numMeasureDev;
        private AutoTextEditField observation;
        private EditField lecture;
        private ObjectChoiceField choice;
        private EditField date;
    
        //Persistent data
        private static Vector data;
        private static PersistentObject store;
    
        //Resource bundle variable
        private static ResourceBundle _res;
    
        //MAIN
    
        public static void main(String[] args){
            measure app = new measure();
            app.enterEventDispatcher();
        }
    
        //Save Menu
        private MenuItem saveItem = new MenuItem(_res, SAVE, 110, 10){
            public void run(){
                StoreInfo nfo = new StoreInfo();
                nfo.setElement(StoreInfo.NUM, numMeasureDev.getText());
                nfo.setElement(StoreInfo.LEC, lecture.getText());
                nfo.setElement(StoreInfo.DAT, date.getText());
                nfo.setElement(StoreInfo.SEL, _res.getString(choice.getIndex()));
                nfo.setElement(StoreInfo.OB, observation.getText());
                data.addElement(nfo);
    
                //Storing data
                synchronized(store){
                    store.setContents(data);
                    store.commit();
                }
                Dialog.inform(_res.getString(APP_SUCCESS));
                numMeasureDev.setText(null);
                lecture.setText(null);
                date.setText(null);
                choice.setLabel(null);
                observation.setText(null);
            }
        };
    
        //Get Menu
        private MenuItem getItem = new MenuItem(_res, GET, 110, 10){
    
            protected int index;
    
            public void run(){
                synchronized(store){
                    data = (Vector) store.getContents();
                    LabelField label = new LabelField();
                    label.setText("Selecciona el dato a mostrar: ");
                    BasicEditField bef = new BasicEditField();
                    index = Integer.parseInt(bef.getText());
                    if (!data.isEmpty()){
                        StoreInfo nfo = (StoreInfo) data.elementAt(index);
                        numMeasureDev.setText(nfo.getElement(StoreInfo.NUM));
                        lecture.setText(nfo.getElement(StoreInfo.LEC));
                        date.setText(nfo.getElement(StoreInfo.DAT));
                        choice.getIndex();
                        observation.setText(nfo.getElement(StoreInfo.OB));
                    }
                }
            }
        };
    
        //Persistent Object
        static{
            //Resource Bundle
            _res = ResourceBundle.getBundle("measure");
    
            //Get the reference to PersistentObject and set value to Vector if is empty
            store = PersistentStore.getPersistentObject(0xdec6a67096f833cL);
            //key is a hash
            synchronized(store){
                if (store.getContents() == null){
                    store.setContents(new Vector());
                    store.commit();
                }
            }
        }
    
        //Class created for a persistent object StoreInfo
        private final static class StoreInfo implements Persistable{
    
            //Data for elements
            private Vector elements;
    
            //Fields
            public static final int NUM = 0;
            public static final int LEC = 1;
            public static final int SEL = 2;
            public static final int OB = 3;
            public static final int DAT = 4; 
    
            //in StoreInfo, add a new empty Vector with capacity of 4 elements and persist
            public StoreInfo(){
                elements = new Vector(5);
                for(int i = 0; i < elements.capacity(); ++i){
                    elements.addElement(new String(""));
                }
            }
    
            //Retrieve Vector element
            public String getElement(int id){
                return (String) elements.elementAt(id);
            }
    
            //Set Vector Element
            public void setElement(int id, String value){
                elements.setElementAt(value, id);
            }
        }
    
        //Measure constructor declaration
        public measure(){
    
            //Create a main screen
            MainScreen mainS = new MainScreen();
            mainS.setTitle(_res.getString(APPLICATION_TITLE));
            numMeasureDev = new EditField(_res.getString(TEXT1),"",
                    Integer.MAX_VALUE, EditField.FILTER_NUMERIC);
            lecture = new AutoTextEditField(_res.getString(TEXT5),"",
                    Integer.MAX_VALUE, EditField.FILTER_NUMERIC);
            date = new EditField(_res.getString(TEXT6),"");
            choice = new ObjectChoiceField(_res.getString(TEXT2),_res.getStringArray(OPTION));
            observation = new AutoTextEditField(_res.getString(TEXT3),"");
    
            //Adding elements to Screen
            mainS.add(numMeasureDev);
            mainS.add(lecture);
            mainS.add(date);
            mainS.add(choice);
            mainS.add(observation);
    
            //Adding menuItems to menu
            mainS.addMenuItem(saveItem);
            mainS.addMenuItem(getItem);
    
            //Push all elements to screen
            pushScreen(mainS);
        }
    }
    

    If anyone knows what I m hurt you showme how please!

    Two thoughts:

    1. If you have changed somehow the object type that you want to keep, you must remove the Simulator files before running again.
    2. How about you provide a clue as to where the class cast exception that happens? You are more likely to help in this way.
  • PersistentStore is not persistent between the device restart

    Hello

    I use the PersistentStore to store a hash table with an integer simple mapping custom of POJO. It seems to work between the restarts the application, IE, I can totally my application and restart and persistent data are restored. However, after a reboot of the appliance, such as pulling on the battery, the data are there not more and everything is reset to 0 by default. Same thing happens on the Simulator.

    I certainly call the commit() every time I change the contents of the table of hash and that in a thread safe way. Nothing appears in the journal of the events, or all exceptions...

    It's with OS 4.6.0 and in this case a "BOLD".

    One with ideas or similar issues that I could hurt?

    Thank you.

    Daniel

    Right, I found the problem: all the objects you want to persist must implement the Persistable interface. Too bad there is no word about it in the JavaDoc of PersistentStore and PersistentObject and too unfortunate that PersistentObject.setContent () takes an object as a parameter instead of an instance of a Persistable implementation. That probably has to do with the fact that the implementation allows implicit persistables objects as the Java object representatives for more than native data types Hashtable and vector.

  • Persistent data and uninstall an app problem.

    Hello

    I'm checking the storage of persistent data with a very silly application, but maybe I'm do sth wrong as that it does not work as I supposed it should.

    My application only checks if there is some content in the store persistent and if not, it creates. I want to check that when the application is uninstalled, these persistent info will be deleted, but as I just test, it is not.

    This is my code:

     public TestP(){
            String info = "nothing";
            synchronized(store) {
                String currentinfo = (String)store.getContents();
                if(currentinfo == null) {
                    //we create it
                    String contents = "something";
                    store.setContents(contents);
                    store.commit();
                } else {
                    //we retrieve it
                    info = currentinfo;
                }
            }
    
            MainScreen ms = new MainScreen();
            ms.add(new LabelField("Testing Persistance..."));
            ms.add(new LabelField(info));
            ms.add(new LabelField("That's all..."));
    
            pushScreen(ms);
        }
    

    And that's how I create the store

    'com.app.test.TestP' at long---> 0xcdbcc77c2e7ecf8cL
    Bank private static PersistentObject = PersistentStore.getPersistentObject (0xcdbcc77c2e7ecf8cL);

    The first time I run my application, the display will return to "nothing" and the text next time 'something '. It's ok, but when I uninstall my application, the first time also shows 'something', which according to me, that he should not be allowed.

    I do something wrong?

    How persistent store information can be removed on an uninstall of the application?

    Concerning

    Your persistent data are of type String, which is a common object of the rim.  It is not necessary for the BB to delete your data - another application can use it.

    However, if you used one of your own classes - even if it comes extends the string and does nothing else - then it will be deleted when your Application is removed, because with your driveway application, there's nothing on the device which includes that Object.

  • Roots FileConnection and application folders names

    I read the forums, guides and the developer APIs, but I'm still looking for a few details on works on BlackBerry FileConnection. I am writing an application that will work with the configuration entry minimum of the user on all devices running 4.2.1 and upward.

    1. is store / and SDCard / internal always the name of the memory and the SD card roots?

    2 JSR 75 leaves open the question of whether an application sees the virtual roots that are private to itself or if all applications share the same roots. How does on BBs? I have seen many examples where the path name starts by "/ store/home/user //" or "/ SDCard/BlackBerry // '. Is this necessary, or can my request simply use "/ store /" or "/ SDCard / and add the file name? If the former, are there best practices documented anywhere to manage collisions between apps?

    3. If the files are visible in many applications, there are layers of security available to protect data (I think something similar to how a PersistentObject can be encapsulated in a ControlledAccess object when you use the PersistentStore) or do make us our own?

    Thanks for the pointers on these issues!

    1. to Yes date, but that could change.  It is recommended to use the FileSystem.listRoots method to get a list of valid root file systems.

    2. all applications share the same roots on BlackBerry mobile devices.  It is recommended that applications create their own folder to store their files in.

    3. There is no integrated in JSR 75 access restrictions that would prevent another application to open your file.  You can encrypt your data to prevent other applications to see your raw data.  Here are some examples on how this can be done:

    How - to use basic encryption
    Article number: DB-00107

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800779/How_to _...

    How to - use encryption advanced
    Article number: DB-00106

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800779/How_to _...

    4. This is true and also applies to the micro SD card.

    5. political IT may restrict access to built in memory and the micro SD card.  You can see the COMPUTER of the BlackBerry Enterprise Server Administrator's policy reference guide for more information on COMPUTER strategies.  A FileConnection may also be restricted based by application using Application control policy.  This can be set on the BlackBerry Enterprise Server (for advanced users applications) or modified by the user (Options, Advanced Options, Applications, change the permissions).  An application can also request a change in the permission by using the ApplicationPermissions class.

    6. mobile devices blackBerry have no unique file name restrictions.  What works in Windows should work on a BlackBerry handheld.

  • PersistentObject / PersistentStore with different names

    Hi all

    I'm new to PersistentObject... As I've never used...

    As RecordStore can create PersistentObject / PersistentStore with a different name...

    I have a title and under each title, I have a list of things that...

    I want to keep this list with the name of the title as we do in recordStore.

    Is it possible with PersistentStore / PersistentObject

    It will be great for any snippet of code

    Thank you

    Thank you...

    This means that if I do the following

    long MY_DATA_ID = 0x33abf322367f9018L;

    PersistentObject persistentObject = PersistentStore.getPersistentObject (MY_DATA_ID);

    long MY_DATA_ID1 = 0x33abf322367f122L;

    PersistentObject persistentObject = PersistentStore.getPersistentObject (MY_DATA_ID1);

    long MY_DATA_ID2 = 0x33abf32236723238L;

    PersistentObject persistentObject = PersistentStore.getPersistentObject (MY_DATA_ID2);

    This refers to three different objects/storage... we use for the other name RMS... Is it?

  • The names of COD for separate free and full versions?

    App smartphone with the free and full (paid) version, both are distributed as different applications. How to name the COD files?

    (1) MyAppFree.cod and MyAppFull.cod

    (2) MyApp.cod (free is version 1.0.1 and complete is the 2.0.1 version)

    In the case of 1) if the user install the free version and then buy the full version, it will be two icons of the same application. Moreover, I have to change the package names if there PersistentObjects it would cause a conflict of app.

    Case 2) if the user purchases the full version to overwrite the free version (it comes will count as an upgrade, given that COD names are the same, and provider is the same)

    Case 2) in theory is better, but given my bitter experience AppWorld I don't know how it works in reality.

    Any ideas?

    It's very simple, really.

    Have the paid version to check the presence of the free or trial... He sends immediately a stop signal to the "lower" version (if it has a background process) and mark it for deletion at the next reset.

    The trial or free version also checks for the presence of the paid version, turns off and converts its opening screen a message saying: thank you for buying the paid version and this app will be gone when you reset.  Then, it is marked for deletion.

    I use this method for a long time, and it works.

    Also, you need not the names of different package whenever it is another name of COD, not only because the store persistent... it will give an error of duplicate class definition and no applications will not work.

    You can use a single KEY for both if you use purchase app or the license keys with try & buy, but it doesn't always work, you get ppl complain they bought it and it has expired.

  • Vectors and vectors and storage

    Hi, I'm new to the idea of a persistent storage. But I managed to just simply record a channel... that's all

    I will try to implement vectors with persistent storage.

    I want to however the following questions were answered.

    1. A vector can be stored on other things in addition to the elementary data types? For example a vector can store the Editfields or LabelFields with content?
    2. A vector stores objects; Does that mean that I can create a custom object and then make a vehicle more of one of my custom object? How to make a custom object?
    3. What is casting? What is its use?

    If you look at the doc for PersistentObject, you will find a list of objects that are implicitly persistent - this includes the String and vector.  If you look at the Persistable doc, you will find a list of other objects that are persistable.  If you want to create a persistent object, you can create using or extend them, by ensuring that all of the classes that are added to the object (or collection) implement also Persistable, directly or by implication.

    Note that you must explicitly define an as Persistable class.  If you say

    class MyString extends {String

    }

    then MyString is not persistent.

    I hope that now I understood and answered all of your questions!  Sorry to not do it at the beginning.

  • Problem with PersistentObject.

    Hi all

    I am new to the BB and bad English (I'm Thai), sorry if you confuse in my words. I have a project that has thead to download the server image and record in PersistentObject using my CustomHashTable. The problem is that I have an error message "NonPersistableObjectException", which is based on the method "persistentObject.commit ();" in "getEncodedImage()" when I debug, here is my code.

    public class TestApp extends UiApplication{
    
        public static void main(String[] args) {      UiApplication app = new TestApp();        app.enterEventDispatcher();   }
    
      TestApp(){        pushScreen(new TestScreen()); }}
    
    public class TestScreen extends MainScreen{
    
       EncodedImage encodedImage;    CustomHashTable persistentHashtable;  private DataInputStream dis;  private byte[] encodeData;    private ByteArrayOutputStream byteStream; PersistentObject persistentObject = PersistentStore.getPersistentObject(0x61a0ab9f850b5c9bL);
    
      TestScreen(){     super();      if (persistentObject.getContents() == null) {         persistentHashtable = new CustomHashTable();          persistentObject.setContents(persistentHashtable);            persistentObject.commit();        }else {           persistentHashtable = (CustomHashTable)persistentObject.getContents();        }     encodedImage = getEncodedImage("http://download.magikmobile.mobi/scodp/mpreview.do?idc=683979&size=140x90&","4952","hot");       encodedImage = scaleImage(encodedImage);
    
          this.setTitle("Test my app");     this.add(new BitmapField(encodedImage.getBitmap()));  }
    
      public EncodedImage scaleImage(EncodedImage image) {      int displayWidth = Fixed32.toFP(Display.getWidth());      int imageWidth = Fixed32.toFP(image.getWidth());      int scalingFactor = Fixed32.div(imageWidth, displayWidth);        EncodedImage scaledImage = image.scaleImage32(scalingFactor, scalingFactor);      return scaledImage;   }
    
      public EncodedImage getEncodedImage(String url, String id, String catagory) {
    
           EncodedImage enc = null;      if (persistentHashtable.containsKey("EncodeImage01")) {           enc = (EncodedImage)persistentHashtable.get("EncodeImage01");     }
    
            if (enc != null) {          System.out.println(">>>>>  image not null");            return enc;        } else {            System.out.println(">>>>>  image null");            try {                String newURL = null;                while (url.indexOf("&") > 0) {                    newURL = url.substring(0, url.indexOf("amp;"));                    url = url.substring(url.indexOf("amp;") + 4);                    url = newURL + url;                }
    
                    newURL = null;                String suffix = "";                HttpConnection httpConnection = (HttpConnection) Connector.open(url+suffix);                httpConnection.setRequestMethod(HttpConnection.GET);                if (httpConnection.getResponseCode() == 302) {                   boolean b = true;                    while (b) {                        if (httpConnection.getResponseCode() == 200) {                            b = false;                            break;                        }                        httpConnection = (HttpConnection) Connector.open(httpConnection.getHeaderField("Location"));                    }                }                dis = httpConnection.openDataInputStream();                int length = (int) httpConnection.getLength();                if (length > 0) {                    encodeData = new byte[length];                    dis.readFully(encodeData);                } else {                    byteStream = new ByteArrayOutputStream();                    int ch;                    while ((ch = dis.read()) != -1) {                        byteStream.write(ch);                    }                    encodeData = byteStream.toByteArray();                    byteStream.close();                    byteStream = null;                }                dis.close();                dis = null;                httpConnection.close();                httpConnection = null;                try {                    enc = EncodedImage.createEncodedImage(encodeData, 0, encodeData.length);                } catch (OutOfMemoryError e) {                  System.out.println(">>>>  OutOfMemoryError");                    e.printStackTrace();                    return null;                } catch (NullPointerException e) {                 System.out.println(">>>>  NullPointerException");                    e.printStackTrace();                    return null;                } catch (IllegalArgumentException e) {                 System.out.println(">>>>>  IllegalArgumentException");                    e.printStackTrace();                    return null;                } catch (ArithmeticException e) {                  System.out.println(">>>>  ArithmeticException");                    e.printStackTrace();                    return null;                }                encodeData = null;                persistentHashtable.put("EncodeImage01", enc);                persistentObject.commit();                catagory = null;                id = null;                url = null;                return enc;            } catch (SecurityException ex) {                ex.printStackTrace();                return null;            } catch (IOException ex) {                ex.printStackTrace();                return null;            }        }    }
    
    }
    
    public class CustomHashTable extends Hashtable implements Persistable{
    
    }
    

    What should I do?

    Thank you very much

    ~ MazMellow ~.

    I see no problem here, hashtable will have any object as second parameter to the function, so you can put hashtable in storage of place (it is supported and commonly used):

    Hash hash = new Hashtable();

    data Byte [] = image.getData ();

    Hash.put ("first", data);

    ....

    ...

    ...

    ....

    data Byte [] (byte []) = hash.get ("first");

    image = EncodedImage.createEncodedImage (data,...);

Maybe you are looking for