I just convert a mp3 file to byte code and reconvert that byte code to mp3 and saved to sdcard, all the process are going successfully but problem is that the saved mp3 file is not playing on device mp3 player it showing unsupported format.
Is there any problem in my below code
private void convertBytesToFile(byte[] bytearray) {
byte[] bytes = bytearray;
String encoded = Base64.encodeToString(bytes, 0);
// Utilities.log("~~~~~~~~ Encoded: ", encoded);
byte[] decoded = Base64.decode(encoded, 0);
//Utilities.log("~~~~~~~~ Decoded: ", Arrays.toString(decoded));
try
{
File file2 = new File(Environment.getExternalStorageDirectory() + "/hello-2.mp3");
FileOutputStream os = new FileOutputStream(file2, true);
os.write(decoded);
os.close();
}
catch (Exception e)
{
Toast.makeText(this, "Somthing wrong", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
or anything am I missing from. Please help friends.