08-30-2012 02:06 AM
Hi all,
I have created two test application for testing record store.
I am using this reference for implementing the same.
First app inserts record in the record store and read from there, and in the second app, I just access that record store.
So now, From the second app, I am unable to access first app record store.
If anyone have some idea regarding the same, then please share.
Thanks in advance.
08-30-2012 02:11 AM
Hi ,
I am thinking that your first app will not be closed proprly!
you can use the database if there is no other app using the same database!
08-30-2012 04:17 AM
I suspect the problem here is that you used the default authorization for the RecordStore, in which case it is private, so only accessible from the creating application.
Have a look at the API, specifically the documentation for this method that you can use when creating the RecordStore.
public static RecordStore openRecordStore(String recordStoreName,
boolean createIfNecessary,
int authmode,
boolean writable)
I think you want authmode set to AUTHMODE_ANY.
08-30-2012 04:43 AM
hi,
you can use below code:
On the producer side, the code can be as follows:
//open a record store for updates.
RecordStore myRecordStore = RecordStore.openRecordStore("ShareableRecordStore"
//set the mode of the record store.
//RecordStore.AUTHMODE_ANY enables the record store to be available outside
//the suite for other MIDlet. The second parameter denotes that
//the record store is shared in read-only mode so that other
//MIDlets would not be corrupting it.
myRecordStore.setMode(RecordStore.AUTHMODE_ANY, false);
//after this the producer MIDlet can do any updates on the record store
//such as add record, update record, or delete a record using the record
//store API.
myRecordStore.addRecord(dataBytes,0,dataBytes.len
myRecordStore.setRecord(recordId, myUpdatedData.getBytes(), 0, myUpdatedData.getBytes().length);
On the consumer side, the code can be as follows:
//On the consumer side there needs to be an implementation
//of the RecordListener interface which demands to have 3
//functions to be coded:
//1.public void recordAdded(RecordStore aRecordStore, int aRecId)
//2.public void recordChanged(RecordStore aRecordStore, int aRecId)
//3.public void recordDeleted(RecordStore aRecordStore, int aRecId)
//where aRecordStore is handle to the store and aRecId is the Id of the
//affected record.
//open the record store by providing the details
RecordStore myRecordStore = RecordStore.openRecordStore("ShareableRecordStore"
//register for the updates
myRecordStore.addRecordListener(this);
//here "this" denotes the object that implements RecordListener
//whenever the producer updates the record store the appropriate
//function (recordAdded/recordChanged/recordDeleted) shall be called
//when there is no need for updates, unregistration can be done
myRecordStore.removeRecordListener(this);
thanks,
08-31-2012 02:59 AM
Hi Anand04, Thanks for quick reply.
Actually I am creating two different Blackberry application using Blackberry Java Plug-in for Eclipse.
I tried your approach too. But in the second app(Consumer side), the following line gives the exception 'RecordStoreNotFoundException'.
//open the record store by providing the details
RecordStore myRecordStore = RecordStore.openRecordStore("ShareableRecordStore","ProducerMidletSuiteVendor","ProducerMidletSuite");
If you have any idea regarding the same, then please help.
Thanks in advance.
08-31-2012 05:25 AM - edited 08-31-2012 05:26 AM
Hi noopesh,
if you have problem with RecordStore, can you use Persistent Store in your application?
Persistent store data is sharable between multiple app without any permission and easy to use in BB.
thanks,
08-31-2012 05:35 AM