I want to access an image stored in Blackberry, say at location "store/home/user/image.png" .
Now can i access this image as,
String filePath = "file:///store/home/user/image.png;
Bitmap image = Bitmap.getBitmapResource(filePath);
BitmapField bitmapField = new BitmapField(image, BitmapField.FOCUSABLE);
OR
I have to access it as,
String filePath = "file:///store/home/user/image.png;
FileConnection fconn = (FileConnection)Connector.open(filePath, Connector.READ);
if (fconn.exists())
{
........
........
input.close();
fconn.close();
}
I am able to access the image using the second way but I want to know that can I access it using "Bitmap.getBitmapResource(filePath)" ?
What language are you writing in? Here's how I did it in C++ on Windows Mobile:
wchar_path
would be something like\\Storage Card\\test.bmp
.Take a look at Bitmap.getBitmapResource API reference:
This method is used to retrieve resources code modules. If you include some image into your project you will be able to retrieve it with this method.
And if you want to open some image from file system, you will have to use FileConnection, check file MIME type, read it's bytes from stream and create EncodedImage accordingly.
Bitmap.getBitmapResource() is used for loading resources that are stored within your COD file or any COD file your application relies on. It is not for loading files that are stored on the device.
Bitmap JavaDocs