Ruben JG
Ruben JG

Reputation: 97

Image to base64

How can I convert all the images stored in one folder to base64 data? in the following code tFotos is the folder where all my images are stored.

ArrayList<String> mList = new ArrayList<String>();
Bitmap selectedImage = BitmapFactory.decodeFile( Environment.getExternalStorageDirectory()+"tFotos");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
selectedImage.compress(Bitmap.CompressFormat.JPEG, 100,
                        stream);
byte[] byteArray = stream.toByteArray();
String strBase64 = Base64.encodeToString(byteArray, 0);
mList.add(StrBase64);

Upvotes: 0

Views: 117

Answers (1)

Rhn Bhadani
Rhn Bhadani

Reputation: 294

@Ruben JG You have to provide full path of image like sdcard/foldername/filename.PNG/.JPEG

Upvotes: 1

Related Questions