PersistentStore NullPointerExeption
I know that this error has to do with the return and or null entry. I can't understand how his ending with null. I don't have to change the application of RuntimeStore to PersistentStore and this application I'm sure that missing a few things as I havn't worked with before PersistentStore.
Here's the code pertaining to PersistentStore areas:
static { persist = PersistentStore.getPersistentObject(Options_ID); if(persist.getContents() == null) { persist.setContents(new Hashtable()); persist.commit(); } options = (Hashtable)persist.getContents(); }
int displaytimeR = 0, timeslotR = 0, timelayoutR = 1, timehotR = 20; int displayDateR = 1, displayDatePositionR = 0, layoutdataR = 1, hotdataR = 4; int weatherDisplayR = 1, weatherDisplayPositionR = 0, weatherLayoutR = 3, weatherhotR = 23; if(persist.getContents() != null && persist.getContents() instanceof Hashtable) { displaytimeR = tmtth.convertToInt(options.get("displaytime")); // Time starts here! timeslotR = tmtth.convertToInt(options.get("timeslot")); timelayoutR = tmtth.convertToInt(options.get("timelayout")); timehotR = tmtth.convertToInt(options.get("timehot")); displayDateR = tmtth.convertToInt(options.get("displaydate")); // Date starts here! displayDatePositionR = tmtth.convertToInt(options.get("displaydateposition")); layoutdataR = tmtth.convertToInt(options.get("layoutdata")); hotdataR = tmtth.convertToInt(options.get("hotdata")); weatherDisplayR = tmtth.convertToInt(options.get("displayweather")); // Weather starts here! weatherDisplayPositionR = tmtth.convertToInt(options.get("displayweatherposition")); weatherLayoutR = tmtth.convertToInt(options.get("weatherlayout")); weatherhotR = tmtth.convertToInt(options.get("weatherhot")); } displayTime = displaytimeR; choicePosition = timeslotR; timeLayout = timelayoutR; timeHot = timehotR; dateDisplayChoice = displayDateR; dateDisplayPosition = displayDatePositionR; layoutData = layoutdataR; hotData = hotdataR; weatherDisplayChoice = weatherDisplayR; weatherDisplayPosition = weatherDisplayPositionR; weatherLayout = weatherLayoutR; weatherHot = weatherhotR;
/* Check to see if it already exists */ if(options != null) { PersistentStore.destroyPersistentObject(Options_ID); persist.commit(); } /* Input the data into the hashtable */ options.put("displaytime", displaytime); options.put("timeslot", timeslot); options.put("timelayout", timelayout); options.put("timehot", timehot); options.put("displaydate", displaydate); options.put("displaydateposition", displaydateposition); options.put("layoutdata", layoutdata); options.put("hotdata", hotdata); options.put("displayweather", displayweather); options.put("displayweatherposition", displayweatherposition); options.put("weatherlayout", weatherlayout); options.put("weatherhot", weatherhot); persist.setContents(options); persist.commit();
Any help to point me in the right direction would be much appreciated!
Thank you
The f
I solved this problem. It was because I was trying to store a variable, what was intended, I wasn't too sure as to which one.
Thanks for the help, as always
Tags: BlackBerry Developers
Similar Questions
-
When exactly PersistentStore get deleted?
I've seen this issue mentioned in http://supportforums.blackberry.com/t5/Java-Development/Best-Practices-for-Storing-Application-Confi...
but I would ask explicitly. So I'm not actually remove objects from PersistentStore, when and how are they destroyed as the application is removed or changed? In particular, I am interested in a few aspects:
1. the impact of my object is a native class as Hashtable vs my own derived class 'MyHashtable' which is not referenced elsewhere.
2 deleting an application compared to upgrade an application in place.
Any help is appreciated.
Thank you
Jim
If you store a clean class (that implements persistable) the store is deleted when the application is removed.
If you store a generic class, what it is not.
-
Hi all
I am trying to identify what is the maximum feature that can be implemented in a BlackBerry application so that updated/uninstall does not reboot of the device.
Official information about the persistent objects:
==== KB ====
... The application contains a live referenceto a persistent object. ...
= Forum =.
http://rim.lithium.com/T5/Java-development/error-module-is-in-use/m-p/131618
.... What exactly does it mean that "The application contains a live reference to a persistent object"? More specifically what does "live" mean? .... This is an "uncommitted" modified persistent object that is in use by the application. ....
My current tests show that once you have something stored in PersistentStore, uninstall / upgrade will require restarting the device. Can someone please confirm this or explain what is wrong with my test script (code to follow)?
Your application being started has nothing to do with the fact that there is a direct reference from your application to the persistent store. At the start of the system, the operating system made a lot of analysis of existing modules, whether or not they are reported to run at startup. During this analysis, it will link the custom object in the modules in your application's persistent store. (This analysis also makes it possible for the system automatically removes the persistent, custom objects that have been orphaned by an application being uninstalled.)
As Simon posted, is not having an object persistent, but having a custom persistent object that forces a restart. Try your experience using a hash instead of a ConfigObject table.
Note that the downside of using a generic object as the Hashtable class is that the persistent data of your application will not disappear when your application is removed.
-
PersistentStore.getPersistentObject returns the null value?
I use a random key to retrieve a shape of the object PersistentStore
persist is PersistentStore.getPersistentObject (KEY);.
Works fine on the Simulator (OS 5), when I take the code signed to the device (BB OS 5.0 Bold 8900)
For some reason, it returns null, without exception. Thereafter any API I inoke on PersistentStore / persist returns null without exception persist even when the null value.
I don't know if it's one thing to eclipse debugger, but even if the debugger shows that objects are null. Controls null applied in the code seems to fail, what does code see these objects as non-null. Pheww! How is it possible.
In this code still shows up as null, then safetyTable and orderedkeys. However, the value null check in the failure code.
At a later stage in the code, when I try to access orderedkeys are null again! Are struggling with this problem for two days, all the pointers would be very comfortable.
persist = PersistentStore.getPersistentObject( KEY ); persistOrderedKeys = PersistentStore.getPersistentObject(KEY_ORDERED_KEYS); safetyTable = (Hashtable)persist.getContents(); orderedKeys = (Vector)persistOrderedKeys.getContents(); if (safetyTable == null) { safetyTable = new Hashtable(); persist.setContents(safetyTable); persist.commit(); } if (orderedKeys==null) { orderedKeys=new Vector(); if (safetyTable.size()>0) { Enumeration addressKeys = safetyTable.keys(); while(addressKeys.hasMoreElements()) { orderedKeys.addElement((String)addressKeys.nextElement()); } } persistOrderedKeys.setContents(orderedKeys); persistOrderedKeys.commit(); }
"I don't know if it's one thing to eclipse debugger.
I had problems of this kind when I don't have a level of operating system for the device I am debugging on.
-
PersistentStore save time?
I have HT a DateField here. And I want to keep his time when I click on something once the field is changed.
myClock = new DateField ("myclock", Long.MIN_VALUE, DateField.TIME)
PersistentStore support it? If not., which api can do?
You can use getDate(), to get a long and then save the persistentObject long
-
using PersistentStore or sqlite to cache feeds the server
Hello world?
I'm get the stream from my server at intervals lets say 5 minutes and I want to be able to cache that feeds from the server (electronic data interchange is json), now I am confused it will be wiser to use sqlite to store these data or I use the persistentstore, my confusion is the persistent vector size against the size of the sqlite database and also performance and efficiency in operations reaad and writing Thank you.
Download 5 MB every 5 minutes seems to be wrong. But maybe I'm old fashioned.
If you treat it just like a sequential file, you could just stick it on the SD card yourself, it will be faster, but much less flexible than SQLite. .
For a file of this size, I would not put it in the persistent store if it was for all those consumers who might have small curve devices. But if you target it to the high end of recent phones, then 5 MB is not a concern, and it would be much easier.
-
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?
-
PersistentStore.ObjectdestroyPersistent
Hello everyone!
How can I remove the Runtime object persistent data?
When I do PersistentStore.ObjectdestroyPersistent it removes only after I closed my request. I need to update my object persistent at runtime, and not after I close my application.
Can someone help me?
Hi rentepatrick,
You need not destroy the persistent store so that you can update its content. As mentioned by peter_strange, you can simply call setContent. You can see the dev guide. There are a few examples precisely against the persistence storage.
-
Persistence of the PersistentStore
I'm developing an app for BlackBerry to keep track of certain information even when the power is off. I was planning on using a PersistentObject but I wanted to know if there is a way for the user to remove items from the PersistentStore. I thought to remove the battery could remove everything in the PersistentStore but I couldn't find anything in the documentation on the subject.
From my experience the PersistentStore remains through the device resets, removing the battery, etc..
Also of the API doc: "the persistent store provides a way for objects to persist across device resets."
-
Problem in PersistentStore - Delete.
Hi friends,
In my application, I have a connect/disconnect feature. First time if I'm logged in, im, store the Userid in my object persistent. When I go the logout button, im trying to remove the persistent data using the code below then it will redirect in 'login screen.
PersistentStore.destroyPersistentObject (0xe63e08aacd575338L);
Now second time if I logged in different userid, taking the last name of user. If its not to remove...
After disconnection so I got out of the application... its working fine. Its taken good userid...
where im making mistake?
Thank you
Karthika J
I'm sorry that I do not understand the case of use that you have described. Can go you through them even step at a time.
Generally however in this case I do not delete the persistent store, instead I put the value to something as empty, and I check to detect that I need to ask the connection information.
-
RecordStore and PersistentStore
Hello
When a user to uninstall or remove an application from BB of the device to store data or PersistentStore are deleted? How it works?
Thanks in advance!
I meant an object class that implements implicitly Persistable; they are documented in the documentation of the API for PersistentObject. It would be a class that you define in your code as a Persistable execution.
In the code, you now use the persistent object is a hash table. It is not removed when your application is removed. If you want to change this, extend Hashtable with your own class. (As described in the documentation for Persistable, you will need to explicitly declare that your subclass implements Persistable.)
-
PersistentStore and KEY identifier
Hello
Sorry if this has been posted before, but using a search by keyword on this forum helped me...
I want to know how to generate the hash key used as a 'unique identifier' when using a PersistentStore?
I know this hash is generated by a string that identifies the path of the 'package', but I do not know how to generate a.
Best regards
Strato
Hi BBDeveloper!
Thanks, this is exactly what I want!
Thank you very much!
Best regards
Strato
-
Questions about PersistentStore/PersistentObject
Hi all!
This is my first post and also a newbie on blackberry development.
Before I start to develop one, I first some ideas on PersistentStorage.
My questions are the following:
1. What is the maximum size of the PersistentStore?
2. what the read/write speed? I ask this question because I need to store data about 200 k.
. One of my colleagues use before RMS but he can't handle the kind of data that we have to handle.
Example, it takes 20 seconds to write 50 K with RMS data.
If it is a byte array, then you don't need to do any conversions to store in RMS. That said, I see no reason, except compatible with J2ME devices, than you would. So I recommend you Persistentstore.
About your second question, I'm not sure that understand how you would sort an array of bytes.
In addition, these two are the mechanisms of persistence, rather than data management mechanisms. If RMS or Persistentstore will directly help you with this sort of thing, but given that Persistentstore can be used to store objects, not just bytes, you will probably find it much easier to work with.
If you plan to do the filtering, searching, sorting etc then you should look at SQLite.
-
Hi all
To apologize for such a newbie question. I read the tutorial "PersistentStorage" and everyhing is clear to me, except for one thing.
private static long key = 0xdec6a67096f833cL; static { _objStore = PersistentStore.getPersistentObject(key); synchronized(_objStore){ if (_objStore.getContents() == null ){ _objStore.setContents(new Vector()); _objStore.commit(); } } _data = (Vector) _objStore.getContents(); }
Where to get/get key? Is is something that you need to generate in advance? If it is, how to generate? There is absolutely no info on this key on the tutorial... It's right here...
Choose a channel which is likely to be unique (for example, the name qualified full of the main class of your application). Type in a comment (to keep Eclipse to complain):
com.example.blackberry.MyApp
Then highlight the string, right-click and select "Convert String to Long" in the menu. Now, you get a key. You can write a second line of comments to the document where it comes from.
I forgot where I heard this, but it was the rim documents somewhere. I agree that it is not documented where you are likely to be read when you need it (like the API docs for PersistentStore).
-
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.
Maybe you are looking for
-
Changed D durning System Recovery drive
Currently, I did a system restore, and earlier, I realized that my D drive is missing. How can I get the D back Player (which plays music and movies) [IMG] http://i36.tinypic.com/ris0vk.jpg [/ IMG] http://i36.Tinypic.com/ris0vk.jpg PS I have windows
-
HP C7200 all-in-One printer will not print via Wifi network
I used the HP printing and scanning of doctor, but none of the proposed solutions have solved the problem. Blue light for service 802.11 g wirelwss is turned on and connected to the same Wifi address as my laptop is now using. My Dell laptop is runni
-
BlackBerry Smartphones sync will not sync all calendar items
Everything worked fine until a few days ago, well I noticed it this morning. My Outlook calendar has NOTHING of my future appointments. I don't know how or why they were deleted. Appointments are on my Black Berry Torch schedule, but they will not s
-
Hi all(1) we have 8 different folders in a single project, all records of these 8 contains the mappings and pointing to 8 different schema. and I've created packages. We have little packages that require mappings of FILE 1 and FILE 2 and also train F
-
How to prevent the VMware Tools reset the size of my text on 4 k display
HelloI use 12 Workstation on a Dell XPS 15 9550 with a native resolution of 3840 x 2160 (4 k). I was able to move on virtual machines running Win 7 from another system where the virtual machines were running at a resolution of 1920 x 1080. These vi