Halo
Halo

Reputation: 729

Bitmap always show null?

In my program, I have to change image path to bitmap. The image path is already exit but when I change to bitmap, bitmap always show null. I don't know what happen.Here is my code.

String dirName = Environment.getExternalStorageDirectory().toString()+picturePath;
     File sddir = new File(dirName);

         Bitmap myBitmap = BitmapFactory.decodeFile(sddir.getAbsolutePath());
            //Drawable d = new BitmapDrawable(getResources(), myBitmap);
         Log.i("mybitmap",myBitmap+"");

     Log.i("dirName",dirName+"");
     Log.i("FileName",sddir+"");

Please, give me some advice...

Edit: Logcat output:

01-19 11:56:18.085: I/mybitmap(1469): null
01-19 11:56:18.085: I/dirName(1469): /mnt/sdcard/mnt/sdcard/447650.jpg
01-19 11:56:18.085: I/FileName(1469): /mnt/sdcard/mnt/sdcard/447650.jpg
01-19 12:19:59.754: I/PicturePath(1671): /mnt/sdcard/62afbdb0c0d287195c0eb7793427b8b8.jpg

Upvotes: 1

Views: 81

Answers (1)

Binoy Babu
Binoy Babu

Reputation: 17119

Your bitmap path is wrong, you are appending the path to sdcard twice. Try this:

Bitmap myBitmap = BitmapFactory.decodeFile("/mnt/sdcard/447650.jpg");

OR

Bitmap myBitmap = BitmapFactory.decodeFile(picturePath);

OR

Make picturePath the path relative to the path of sdcard.

Upvotes: 1

Related Questions