A resource bundle can be built using Ant during the standard application build process. Resource files convert existing files into bundles as necessary. An application can have any number of resource files.
A resource file is loaded fully into memory (due to Java ME IO constraints), so you should group resources based on the needs of the application flow. This allows the application to load only the necessary resources for a given form or use case, and leaves free memory for additional resources needed by other forms or use cases.
To create a resource, use code similar to the following example in your build file:
<taskdef classpath="editor.jar" classname="com.sun.lwuit.tools.resourcebuilder.LWUITTask" name="build" /> <build dest="src/myresourceFile .res"> <image file="images/myImage.png" name=”imageName” /> </build>
You can add several additional types of resources to the build tag. These optional resource tags are explained in the remainder of this chapter.
To load a resource into your application, use code similar to this:
Resources res = Resources.open(“/myresourceFile.res”); Image i = res.getImage(“imageName”);