src/jpm/dg/MediaActivity.java
/**
	 * Saves an image to the "Personal" folder.
	 * @param fileName The filename to use for the image.
	 * @param bmp The Bitmap object of the image.
	 * @return True if and only if the image was successfully saved.
	 */
Saves an image to the "Personal" folder.
@param fileName The filename to use for the image.
@param bmp The Bitmap object of the image.
@return True if and only if the image was successfully saved.
Saves an image to the " Personal " folder . @param fileName The filename to use for the image . @param bmp The Bitmap object of the image . @return True if and only if the image was successfully saved .
public boolean saveImage(String fileName, Bitmap bmp) {
		if (bmp != null && !bmp.isRecycled()) {
			File storagePath = new File(Environment.getExternalStoragePublicDirectory(
		            Environment.DIRECTORY_PICTURES).toString() + "/Personal"); 
		    storagePath.mkdirs();
			FileOutputStream out = null;
			File imageFile = new File(storagePath, String.format("%s.png",
					fileName));
			try {
				out = new FileOutputStream(imageFile);
				bmp.compress(Bitmap.CompressFormat.PNG, 100, out);
				ContentValues values = new ContentValues(3);
				values.put(Images.Media.TITLE, "image");
				values.put(Images.Media.MIME_TYPE, "image/png");
				values.put("_data", imageFile.getAbsolutePath());
				getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
			} catch (Exception e) {
				e.printStackTrace();
				return false;
			} finally {
				if (out != null) {
					try {
						out.flush();
						out.close();
					} catch (Exception e) {
						e.printStackTrace();
						return false;
					}
				}
			}
			return true;
		}
		return false;
	}
public boolean saveImage ( String fileName , Bitmap bmp ) { if ( bmp != null && ! bmp . isRecycled ( ) ) { File storagePath = new File ( Environment . getExternalStoragePublicDirectory ( Environment . DIRECTORY_PICTURES ) . toString ( ) + "/Personal" ) ; storagePath . mkdirs ( ) ; FileOutputStream out = null ; File imageFile = new File ( storagePath , String . format ( "%s.png" , fileName ) ) ; try { out = new FileOutputStream ( imageFile ) ; bmp . compress ( Bitmap . CompressFormat . PNG , 100 , out ) ; ContentValues values = new ContentValues ( 3 ) ; values . put ( Images . Media . TITLE , "image" ) ; values . put ( Images . Media . MIME_TYPE , "image/png" ) ; values . put ( "_data" , imageFile . getAbsolutePath ( ) ) ; getContentResolver ( ) . insert ( Media . EXTERNAL_CONTENT_URI , values ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; return false ; } finally { if ( out != null ) { try { out . flush ( ) ; out . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; return false ; } } } return true ; } return false ; }
Saves an image to the "Personal" folder.
Saves an image to the " Personal " folder .