A MIDlet, an application based on the Mobile Information Device Profile (MIDP), has access to two sets of runtime properties: system and application.
The concept of system properties is actually defined by the Connected Limited Device Configuration (CLDC), on which the MIDP is based. The underlying platform sets the properties and the application can obtain their values but cannot change them. The set of system properties varies
depending on what features are available on the platform - see the FAQ "What are the defined J2ME system property names?" for a partial list of common system properties. To read a system property the MIDlet invokes
System.getProperty(), a static method.
Application properties are obtained from the union of the attributes defined in the application descriptor and those in the MIDlet suite's manifest, part of the JAR file packaging. You set their values when you package the application for deployment. Consider a typical application descriptor:
To read an application property like the
Which-Locale attribute in this
descriptor, a MIDlet invokes MIDlet.getAppProperty(), a non-static, instance method. This example code obtains the name of the MIDlet suite by querying the MIDlet-Name property:
Property names are case-sensitive. If a property is not defined by
either the application descriptor or the manifest,
null is returned. If
the same property is defined differently in the application descriptor
and the manifest, the conflict is resolved in one of two ways: If the MIDlet is a trusted application based on MIDP 2.0, the system simply won't install the application. Otherwise, the value in the descriptor overrides the value in the manifest.
Application properties are particularly useful when descriptors are
generated dynamically. For example, you can embed a registration key in
the descriptor that the application will read and pass back to a
registration server the first time it's run, without having to recompile
or repackage the application itself. Don't stuff a lot of data in the descriptor, though, because some platforms limit the descriptor size.
Use application properties wherever you'd use a standard Java properties file in a J2SE application.
| ||||||||||||
|
| ||||||||||||