1

Here i am try to open photo from folder which i saved in before activity of this program's but here i still face the Exception.

ImageView img = null;
Bitmap bmp = null;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.photoeffect_1);
    Intent i = this.getIntent();
    String s = i.getStringExtra("second");
    Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show();

    bmp = BitmapFactory.decodeFile("/sdcard/GWonderPhoto/"+s+".jpg");
    img = (ImageView) findViewById(R.id.imageView1);
    img.setImageBitmap(bmp);
    // TODO Auto-generated method stub

}

Exception :

'02-25 17:07:07.543: E/BitmapFactory(24805): Unable to decode stream: java.io.FileNotFoundException: /sdcard/GWonderPhoto/1424905623242.jpg: open failed: ENOENT (No such file or directory)'

Gautam Patadiya
  • 1,401
  • 14
  • 19

2 Answers2

3

use

setContentView(R.layout.photoeffect_1);

just after

super.onCreate(savedInstanceState);

i.e. rewrite onCreate method as

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
 // TODO Auto-generated method stub
    setContentView(R.layout.photoeffect_1);
    Intent i = this.getIntent();
    String s = i.getStringExtra("second");
    Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show();

    bmp = BitmapFactory.decodeFile("/sdcard/GWonderPhoto/"+s+".jpg");
    img = (ImageView) findViewById(R.id.imageView1);
    img.setImageBitmap(bmp);
}
Giru Bhai
  • 14,370
  • 5
  • 46
  • 74
0
bmp = BitmapFactory.decodeFile("/sdcard/GWonderPhoto/"+s+".jpg");

change this line to:

bmp = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()+"/GWonderPhoto/"+s+".jpg");

EDIT

also see if following permissions are added in Manifest:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

i hope this will help you.

Amrut Bidri
  • 6,276
  • 6
  • 38
  • 80