I would like to decode the base64 string and turn it into a file (like pdf / jpg) and save it on the device, like in (/storage/emulated/0/Download/file.pdf).
To encode a file, I use this code:
File originalFile = new File("/mnt/sdcard/download/file.pdf"); String encodedBase64 = null; try { FileInputStream fileInputStreamReader = new FileInputStream(originalFile); byte[] bytes = new byte[(int) originalFile.length()]; fileInputStreamReader.read(bytes); encodedBase64=Base64.encodeToString(bytes,Base64.NO_WRAP); messaggio=encodedBase64.toString();
Now I would like to deactivate this base64 string and convert it to a file and save it on the device ...
Can someone help me?
Thanks to everyone =)
source share