Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pre-populate a RecordStore before intallation ?

 
Ken Loh
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ken Loh
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic