File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes How to pre-populate a RecordStore before intallation ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "How to pre-populate a RecordStore before intallation ?" Watch "How to pre-populate a RecordStore before intallation ?" New topic
Author

How to pre-populate a RecordStore before intallation ?

Ken Loh
Ranch Hand

Joined: Feb 16, 2005
Posts: 190
Is there a way to pre-populate a RecordStore so that it contains data needed for an application to run right after being installed ?
William Frantz
Ranch Hand

Joined: Dec 08, 2004
Posts: 102
No, but one technique I've used in the past is to put parameters in the JAD file.

When I access a stored parameter, I first check to see if it's in the RMS. If it's not there, I check to see if it's in the JAD. If it's not there, I choose some default value.

William Frantz
http://SprintDevelopers.com
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Here a strategy that i used in one of my applications.

I created a record reader wrapper. In the Initialization of this class, I call a method called checkForFirstTime(), which tries to find one record with String value = recordSource.get("XXX");

if value is null, then I know this is the first time the application has run and create the records. If it is not null it just returns immediately.

Hope that helps.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Ken Loh
Ranch Hand

Joined: Feb 16, 2005
Posts: 190
Thanks William and Mark for your answers.

Mark, just like to understand better - when it is the first time, do you also mean like William, I need to look up for the values from the JAD file when the record hasn't been created yet in the store?


Originally posted by Mark Spritzler:
Here a strategy that i used in one of my applications.

I created a record reader wrapper. In the Initialization of this class, I call a method called checkForFirstTime(), which tries to find one record with String value = recordSource.get("XXX");

if value is null, then I know this is the first time the application has run and create the records. If it is not null it just returns immediately.

Hope that helps.

Mark
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Originally posted by Ken Loh:
Thanks William and Mark for your answers.

Mark, just like to understand better - when it is the first time, do you also mean like William, I need to look up for the values from the JAD file when the record hasn't been created yet in the store?




Well I actually coded the values in my first time method. But you could have it look up the values in the JAD file. Either way works.

Mark
Eduardo Marques
Ranch Hand

Joined: Feb 19, 2005
Posts: 231
Another (previously installed) MIDlet suite could create the record store for the MIDlet you want ... with AUTHMODE_ANY sharing mode and populate the record store. The record store will be shared between all suites.

Well, this is possible but unsuitable for generic use in MIDlets ...

Why don't you just fill in a default value from the JAD file if the record store is not set?


Cheers


Eduardo Marques
Get ready for your SCMAD certification at J2MECertificate.com - See what all the buzz is about ...
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

"Dardo"

Please click on the "My Profile" Link above and change your name to meet JavaRanch's Naming Policy. The policy states using your real first name and real last name.

Thanks

Mark
Eduardo Marques
Ranch Hand

Joined: Feb 19, 2005
Posts: 231
Mark,

Is it ok to use just my login name then?

According to the profile section, this would be acceptable.

If it is not ok, then I guess I�ll use my real name.

Thanks,

Eduardo Marques

edrdo@freeshell.org
William Frantz
Ranch Hand

Joined: Dec 08, 2004
Posts: 102
Originally posted by Eduardo Marques:
Another (previously installed) MIDlet suite could create the record store for the MIDlet you want ... with AUTHMODE_ANY sharing mode...


This is not available on every handset. No Sprint PCS phones support RMS sharing between MIDlets (unless they are part of the same suite).

William Frantz
http://SprintDevelopers.com
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Originally posted by edrdo:
Mark,

Is it ok to use just my login name then?

According to the profile section, this would be acceptable.

If it is not ok, then I guess I�ll use my real name.

Thanks,

Eduardo Marques

edrdo@freeshell.org


Yes, please use your real name Eduardo. Our Policy states using real first and real last names, not login names.

Thanks

Mark
Eduardo Marques
Ranch Hand

Joined: Feb 19, 2005
Posts: 231
Yes, MIDP 1.0 phones do not support it but MIDP 2.0 models should ...

Originally posted by William Frantz:


This is not available on every handset. No Sprint PCS phones support RMS sharing between MIDlets (unless they are part of the same suite).

William Frantz
http://SprintDevelopers.com
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to pre-populate a RecordStore before intallation ?