0
votes

As asked, is it possible? Here's part of my code. I don't know how to change it, please help me!

Bundle b = New_Entry.this.getIntent().getExtras();

String s1 = b.getString("image");

try {

new File("/sdcard/myImages").mkdirs();

InputStream in = getResources().openRawResource(imageSID[position]);

File f2 = new File("/sdcard/myimages"+filename[position]);

OutputStream out = new FileOutputStream(f2);

byte[] buf = new byte[1024];

int len;

while ((len = in.read(buf)) > 0){

out.write(buf, 0, len); }

in.close();

out.close();

} catch(Exception x) {

Toast.makeText(getBaseContext(), "Error!", Toast.LENGTH_SHORT).show();

}

And yes, the error toast came up!

1

1 Answers

0
votes

It looks like you are missing a trailing slash on this line:

File f2 = new File("/sdcard/myimages"+filename[position]);

However, I dont think this would make it crash - it would just cause the image to get written to the wrong file. Can you post a stack trace? It would help to know what line you are crashing on.