I want to save an image from the drawable directory to the download folder in the phone.
The code I was trying is:
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.tradoficial); File sd = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); String fileName = "test.jpg"; File dest = new File(sd, fileName); try { FileOutputStream out; out = new FileOutputStream(dest); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); out.flush(); out.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } But nothing happens on my phone. Is there anything wrong?
Thanks a lot!