How to take screenshot of application and store it in SDCARD?

By | October 26, 2011

The first part is explained in this Tutorial, that is taking the screenshot of the application (View).

The second part is storing it in the SDCARD. This is possible by compressing the image bitmap to bytes and then store.

 ByteArrayOutputStream bytes = new ByteArrayOutputStream();
         bm.compress(Bitmap.CompressFormat.JPEG, 40, bytes);

         File f = new File(Environment.getExternalStorageDirectory()
                                 + File.separator + "test.jpg");
         try {
			 FileOutputStream fo = new FileOutputStream(f);
		} catch (Exception e) {
			// TODO Auto-generated catch block

Finally dont forgot to put the following permission in the manifest file.

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

Leave a Reply

Your email address will not be published.