BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 06-13-2007, 08:27 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Feb 2007
Location: India
Model: 7100v
Carrier: aittel
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Post sharing persistent Object

Please Login to Remove!

I want to access same persistet object from two different applications.
any suggestions on how to do it ?
Offline  
Old 06-13-2007, 08:49 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default Sharing Persisten Objects

If you haven't already looked at the Developer's Guides Check out Volume 2, page 88 Blackberry persistent storage. As long as both applications know the correct ID they can each read the data. If you want to share runtime data, look at page 133. Unfortunately these APIs required signing the binary, but I find them useful.
Offline  
Old 06-14-2007, 09:07 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Feb 2007
Location: India
Model: 7100v
Carrier: aittel
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks hrbuckley,
with the help u provided ,I managed to get the shared objects,
but I am not able to retrieve the data from userdefined class objects.

suppose I want to share the vector which contains ABC class's Object

code which put's the data on runtimeshare

Code:
class ABC
{
   String msg;
}
class ---{
RuntimeStore store = RuntimeStore.getRuntimeStore();  
        ABC abc=new ABC();
        abc.msg = "Hi";
        Vector vec=new Vector();
        vec.addElement(abc);
        long ID = 0x9e281cf2762efac3L;
        // put() throws an IllegalArgumentException if an object with the same ID exists.
        try {
        store.put( ID, vec);
        } catch(IllegalArgumentException e) {
        // Handle exception - an object with the same ID exists.
        }
}

Code which retrieves the data from runtimeshare
Code:
class ABC
{
   String msg;
}
class ---{
 RuntimeStore store = RuntimeStore.getRuntimeStore();
             // Create an object and a unique number to identify the object.        
        long ID = 0x9e281cf2762efac3L;         
        try {
        // get() returns the objectm with the specified ID if it exists; null
        // otherwise.
         Vector vec= (Vector)store.get(ID)
       if(vec.size()>0)
         ABC abc=(ABC)vec.elementAt(0);//gives Error java.lang.ClassCastException

}
can anybody tell me how to solve this Problem?

Last edited by Rojiwadiya dinesh : 06-14-2007 at 09:14 AM.
Offline  
Old 06-15-2007, 02:04 AM   #4 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

as far as I remember, class ABC should implement interface Persistable
Offline  
Old 06-15-2007, 05:30 AM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Feb 2007
Location: India
Model: 7100v
Carrier: aittel
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Skipper_Joe,
I even tried with persistent object Iam getting the same error,but I can
able to get and retrieve the value fo String variable object.

I had an Application1 which puts the data on runtimeshare contains ABC class and another Application2 which receives the data form share also contains the same ABC class,
App1's ABC class doesnot match with App2's ABC class even it contains the same fields .
Is there any solution to solve the above problem?
Offline  
Old 06-19-2007, 02:06 AM   #6 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can't use different classes. 2 different classes are not considered the same even if they have the same set of fields. You need to use the same class definition in both applications.
For example, you can create separate library, which contains definition of class ABS and use it in both App1 and App2.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.