Code example for Bitmap

Methods: getHeightgetRowBytes

0
	 */ 
	public static int getBitmapSize(final Bitmap bitmap) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1)
			return GetBitmapSizeAccessor.getBitmapSize(bitmap);
		// Pre HC-MR1 
		return bitmap.getRowBytes() * bitmap.getHeight();
	} 
 
	/** 
	 * Get the memory class of this device (approx. per-app memory limit) 
	 *  
	 * @param context 
	 * @return 
	 */ 
	public static int getMemoryClass(final Context context) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) return GetMemoryClassAccessor.getMemoryClass(context);
		return (int) (Debug.getNativeHeapSize() / 1024 / 1024);
	} 
 
	/** 
	 * Check how much usable space is available at a given path. 
	 *  
	 * @param path The path to check 
	 * @return The space available in bytes 
	 */ 
	public static long getUsableSpace(final File path) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD)
			return GetUsableSpaceAccessor.getUsableSpace(path);
		final StatFs stats = new StatFs(path.getPath());
		return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
	} 
 
	/** 
	 * Check if OS version has a http URLConnection bug. See here for more 
	 * information: 
	 * http://android-developers.blogspot.com/2011/09/androids-http-clients.html 
	 *  
	 * @return 
	 */ 
	public static boolean hasHttpConnectionBug() { 
		return Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO;
	} 
 
	static class GetBitmapSizeAccessor { 
 
		@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
		static int getBitmapSize(final Bitmap bitmap) {
			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) return bitmap.getByteCount();
			// Pre HC-MR1 
			return bitmap.getRowBytes() * bitmap.getHeight();
		} 
	} 
 
	static class GetMemoryClassAccessor {