Android-conversion between string and Drawable, android-drawable
// Convert the String to Drawable public synchronized static Drawable StringToDrawable (String icon) {if (icon = null | icon. length () <10) return null; byte [] img = Base64.decode (icon. getBytes (), Base64.DEFAULT); Bitmap bitmap; if (img! = Null) {bitmap = BitmapFactory. decodeByteArray (img, 0, img. length); @ SuppressWarnings ("deprecation") Drawable drawable = new BitmapDrawable (bitmap); return drawable;} return null ;} // convert drawable to public synchronized static String DrawableToString (Drawable drawable) {if (drawable! = Null) {Bitmap bitmap = Bitmap. createBitmap (drawable. getIntrinsicWidth (), drawable. getIntrinsicHeight (), drawable. getOpacity ()! = PixelFormat. OPAQUE? Bitmap. config. ARGB_8888: Bitmap. config. ARGB_8888); Canvas canvas = new Canvas (bitmap); drawable. setBounds (0, 0, drawable. getIntrinsicWidth (), drawable. getIntrinsicHeight (); drawable. draw (canvas); int size = bitmap. getWidth () * bitmap. getHeight () * 4; // create a byte array of output streams. The stream size is ByteArrayOutputStream baos = new ByteArrayOutputStream (size). // set the bitmap compression format, it has a quality of 100% and is put into the byte array output stream bitmap. compress (Bitmap. compressFormat. PNG, 100, baos); // convert byte array output to byte array byte [] byte [] imagedata = baos. toByteArray (); return Base64.encodeToString (imagedata, Base64.DEFAULT);} return "";}