playing Audio from BLOB field of a Table of a SQLite DB playing Audio from BLOB field of a Table of a SQLite DB database database

playing Audio from BLOB field of a Table of a SQLite DB


try something like this :

byte[] buffer = new byte[2048];int size = 0;ByteArrayInputStream byteArrayStream = new ByteArrayInputStream(byteAudio2); while ((size = byteArrayStream.read(buffer, 0, buffer.length)) > 0) {    fos.write(buffer, 0, size);}

[]


Perhaps too late but if someone needs it.

This works for me:

 File file; FileOutputStream fos; byteaudio = cursor.getBlob(cursor.getColumnIndex("sonido")); try {        file = File.createTempFile("sound", "sound");        fos = new FileOutputStream(file);        fos.write(byteaudio);        fos.close();        Log.d("File", file.toString());    } catch (IOException e) {        e.printStackTrace();    }mp = MediaPlayer.create(getActivity(), Uri.fromFile(file));            mp.start();