Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 28
Registered: ‎06-15-2010
My Device: 9700
My Carrier: Smartone Vodafone
Accepted Solution

Persistent Data Object Problem

Dear sir,

 

Hi, 

I am writting a module that simply implements the phone listener,

and I'd like to use Persistent Object to store some information

 

But I face the following problems:

When I use the persistent objects, the simulator show that there is no application instance,

as my program does not include any GUI,

would my program just be recognized as a Moudle and the Persistent Object need to point the store data with an appliaction?

thanks a lot

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Persistent Data Object Problem

you can extend application and mark the app as system module without a problem.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 28
Registered: ‎06-15-2010
My Device: 9700
My Carrier: Smartone Vodafone

Re: Persistent Data Object Problem

So when I try to use Persistent Object,

I have to use it with an UiApplication?

as there always exists a error: No Application Instance

But I've made it without any application instance sometimes.

Thank you.

 

Contributor
Posts: 28
Registered: ‎06-15-2010
My Device: 9700
My Carrier: Smartone Vodafone

Re: Persistent Data Object Problem

 

Here is my code:
ublic class Listener implements PhoneListener {
 static long key = 0x52736b202bb32008L;
 static PersistentObject persistentobject = PersistentStore
 .getPersistentObject(key);
 
 public void callConnected(int callId) {
 
 Dialog.alert("Call Connected");
 String s = null;
 synchronized (persistentobject) {
 s = (String) persistentobject.getContents();
 if (s == null){
 Dialog.alert("Null Content in Persistent Object");
 persistentobject.setContents("ABCABCABC");
 Dialog.alert("Content Set: ABCABCABC");
 persistentobject.commit();
}
else {
Dialog.alert(s);
// end of s is null
}
}
}

 

public class Listener implements PhoneListener { static long key = 0x52736b202bb32008L;
static PersistentObject persistentobject = PersistentStore .getPersistentObject(key);

public void callConnected(int callId) { // TODO Auto-generated method stub Dialog.alert("Call Connected"); String s = null; synchronized (persistentobject) { s = (String) persistentobject.getContents();
if (s == null){ Dialog.alert("Null Content in Persistent Object"); persistentobject.setContents("ABCABCABC"); Dialog.alert("Content Set: ABCABCABC"); persistentobject.commit(); } else { Dialog.alert(s); // end of s is null }
}
}

 

it workds on simulator but not no device

and there is always error saying that no application instance Smiley Sad

and would it be the matter of the long key?

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Persistent Data Object Problem

extend Application. Not UiApplication. and enter the event dispatcher.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 28
Registered: ‎06-15-2010
My Device: 9700
My Carrier: Smartone Vodafone

Re: Persistent Data Object Problem

Thanks for your reply,

 

but i am just wondering,

 

whether the peristent object MUST BE used when my program did extends Application.

 

Also, I've used it without extends the Applications and made it.

 

But I found that when I uninstall my program and install again,

 

the persistent object still exists. 

 

which the reference mention about the persistent object would be removed when we uninstall the

 

program...

 

 

Contributor
Posts: 28
Registered: ‎06-15-2010
My Device: 9700
My Carrier: Smartone Vodafone

Re: Persistent Data Object Problem

Thank You.

 

And here is my problem:

 

1. My program does not extends Application and there is no GUI, "no application instance" comes from my Dialog.alert when there is no GUI components.

 

2. Persistent Store does not require your program to extends Application or UiApplication, all the program want is just a key to make a clear address to the storage.

 

3. The persistent store is not recommend to use integer, boolean , string, etc. As this type may be used when your app is uninstall, therefore the data may not be erased.

 

4. When I have made it, I have store a String into the Persistent Store and it is not erased when my program is uninstall, so when I created a class and get content from the Persistent Store, it return the String and not my new class. So there is no response when I get my Contents Smiley Happy