views:

28

answers:

1

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!

A: 

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.

ajh158
Oh my prog didn't crash. I just want to know is it possible to place the passed image value into the sdcard? cause i have to select the image from a.java then a.java will close then b.java will appear, then b.java will have a button and save it into sdcard.
UserA