Greetings:
I am writing an Android app that includes an ImageView. The image to be included in the view resides on the local app directory of the emulator. The image is not being displayed in the view. The relavent XML and method used to display the image are given below.
The image file is a "png" format file and is able to be opened from the local app directory. The path returned by getFilesDir() includes the full path, "/data/data/net.vitalrecord.android/files." This path designation does not exist on the development system but does exists when DDMS File Explorer is used.
Any help with this problem is greatly appreciated.
Thanks.
LAYOUT XML: ......
<ImageView
android:id="@+id/picture" android:layout_width="wrap_content" android:layout_height="wrap_content"/> android:layout_x="100px" android:layout_y="100px" />
Method: public void checkFilesExists() {
.....
try {
Context context = getApplicationContext();
FILENAME = getString(R.string.MedicalImage);
fis = openFileInput(FILENAME);
int size = fis.available();
byte[] buffer = new byte[size];
fis.read(buffer);
fis.close();
setContentView(R.layout.medtogoimage);
ImageView iv = (ImageView)findViewById(R.id.picture);
String imagePath = context.getFilesDir() + "/" + FILENAME;
Drawable d = Drawable.createFromPath(imagePath);
iv.setImageDrawable(d);
medtogo.setbMedicalImageFileExists(true);
} catch (IOException e) {
medtogo.setbMedicalImageFileExists(false);
}