0
			// android:name="android.permission.WRITE_EXTERNAL_STORAGE" 
			// into AndroidManifest.xml file 
			RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
 
			// get the width and height of the source bitmap. 
			int width = imgIn.getWidth();
			int height = imgIn.getHeight();
			Config type = imgIn.getConfig();
 
			// Copy the byte to the file 
			// Assume source bitmap loaded using options.inPreferredConfig = 
			// Config.ARGB_8888; 
			FileChannel channel = randomAccessFile.getChannel();
			MappedByteBuffer map = channel.map(MapMode.READ_WRITE, 0, imgIn.getRowBytes() * height);
			imgIn.copyPixelsToBuffer(map);
			// recycle the source bitmap, this will be no longer used. 
			imgIn.recycle();
			System.gc();// try to force the bytes from the imgIn to be released
 
			// Create a new bitmap to load the bitmap again. Probably the memory 
			// will be available. 
			imgIn = Bitmap.createBitmap(width, height, type);
			map.position(0);
			// load it back from temporary 
			imgIn.copyPixelsFromBuffer(map);
			// close the temporary file and channel , then delete that also 
			channel.close();
			randomAccessFile.close();
 
			// delete the temp file 
Connect your IDE to all the code out there  Get Codota for Java