This section describes the accessing resources on Nokia Asha and Series 40 software platform devices.
On Nokia Asha software platform devices, a MIDlet should keep the memory consumption below 3MB.
Nokia Asha and Series 40 devices use static memory allocation for Java. On most Series 40 devices, the maximum Java heap size is 2 MB, while a few high end devices come with 4 MB of heap. These methods Runtime.getRuntime().freeMemory() and Runtime.getRuntime().totalMemory() return the total memory and free memory and are available in Nokia Asha and Series 40 devices.
When internally representing an Image instance, the platform will create a bitmap-type mapping of the image, no matter what the original format of the image is. As a result, a png file of a few kilobytes can consume a significant amount of Java heap.
The total amount of reserved Java heap depends on the size and color depth of the image, and can be calculated according to this formula:
width * height * (color depth/8)
As an example a png file of 7 kilobytes, with a 16 bit color depth and size 320 x 240 pixels, will consume : 320 * 240 * 2 = 153600 bytes. Exactly 150 kilobytes, which is a lot more than the 7 kilobytes that the image occupies on the device’s file system.
Most Series 40 devices support a maximum JAR size of up to 2 MB. On Nokia Asha software platform devices the Java ME framework allows much larger JAR files.
To find out the maximum Java heap size and JAR size of a device, see Nokia Developer device specifications.
Some devices also impose a maximum size for content to be downloaded to the device. On many devices, the maximum download size for any content is smaller than the maximum allowed application size. This means that users may be able to install larger applications via, for example, PC Suite than what they are able to download over the air.
On the latest Nokia Asha software platform devices, if you have installed an application from the memory device, the application appears dimmed or non-functional in the application view when the memory card is removed. If you transfer the MIDlet to the device with bluetooth, the application is stored and installed in the phone memory and is therefore not affected by the memory card removal.
More information about the exception is available by using Exception.getMessage() method, which is useful in problem solving.
Any exception that is not handled by the application itself, will cause an error message “Unhandled exception” to be presented to the user. User can select if application should be closed or not.
Resources can be accessed using absolute or relative paths - getResourceAsStream method uses more strict rules for accessing resources with relative paths than in previous release (to be in-line with MIDP 2.1 specification).
Relative pathnames are relative to the class upon which getResourceAsStream is called. Relative names are converted to absolute by pre-pending a fully qualified package path.
For example, assuming MIDlet has JAR directory structure illustrated below then getResourceAsStream(“bar.txt”) succeeds but getResourceAsStream(“foo.txt”) fails.
foo.txt
\hello\hello.class
\hello\bar.txt
\meta-inf\Manifest.mf
Previously it was possible to access foo.txt using relative path as well.
Absolute path, getResourceAsStream(“/foo.txt”), should be used to access foo.txt.