Firts you have to check that the string you want to decode is vaild and has the intended value to be decoded and to do so, you can do something like below:
filePath= Environment.getExternalStorageDirectory()
+ "/SaudiScore/temporary_holder.jpg";
Bitmap selectedImage = BitmapFactory.decodeFile(filePath);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
selectedImage.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] byteArray = stream.toByteArray();
String strBase64=Base64.encodeToString(byteArray, 0);
then you can decode the string that you just encoded and get the image back by doing something like the following:
byte[] decodedString = Base64.decode(strBase64, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
image.setImageBitmap(decodedByte);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…