Troubleshooting guide
150
BlackBerry Java Development Environment Development Guide
Retrieve module information
Retrieve an array of handles for existing modules on a BlackBerry device
>Invoke getModuleHandels().
int handles[] = CodeModuleManager.getModuleHandles();
String name = CodeModuleManager.getModuleName( handles[0]);
Create code modules
Task Steps
Retrieve a handle for a module. >Invoke getModuleHandle() and provide the name of the code module as a parameter.
int handle = CodeModuleManager.getModuleHandle("test_module");
Retrieve specific information about a
module.
> Invoke the methods of the CodeModuleManager class and provide the module handle as a
parameter to these methods.
String name = CodeModuleManager.getModuleName( handle );
String vendor = CodeModuleManager.getModuleVendor( handle );
String description = CodeModuleManager.getModuleDescription( handle );
int version = CodeModuleManager.getModuleVersion( handle );
int size = CodeModuleManager.getModuleCodeSize( handle );
int timestamp = CodeModuleManager.getModuleTimestamp( handle );
Task Steps
Create a module without data. >Invoke createNewModule() and provide the size of the module in bytes as a parameter.
int handle = CodeModuleManager.createNewModule( 3000 );
Create a module with data. >Invoke createNewModule(int, byte[], int), providing the following parameters:
• the length in bytes of the entire module
• the byte array to add to the module
• the length parameter to specify the number of bytes from the byte array to add to the
start of the module
static int createNewModule(int, byte[], int);
Write data into a module. You can write data into a code module in increments, as long as you know the offset at which
to add data.
>Invoke writeNewModule() and provide a byte array of data as a parameter to this
method.
Boolean success = CodeModuleManager.writeNewModule( handle, data,
0, data.length );
Save a module to the BlackBerry® device
database.
>Invoke saveNewModule(int). If the module saves successfully, the method returns one
of the result codes defined in the
CodeModuleManager class.
int result = CodeModuleManager.saveNewModule(handle);