Question

I want to make an android application which store the voice of caller in database can anybody tell me how to proceed ?

Était-ce utile?

La solution

You need use MediaRecorder class as follows,

recorder = new MediaRecorder();
int audioSource = MediaRecorder.AudioSource.VOICE_CALL;
recorder.setAudioSource(audioSource);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
final String filePath = Environment.getExternalStorageDirectory() + "/record.3gpp";
final File file = new File(filePath);
file.getParentFile().mkdirs();
recorder.setOutputFile(filePath);
recorder.prepare();
recorder.start(); // Recording is now started

In Above code, I save recorded file in local storage, because we can't store mp3 file into sqlite database. We can store the link to the mp3 in database.

That's why we should store mp3 file in local path(that is in sdcard or in phone memory) and store that local path in Database. When we want to play that mp3 file take local URI from database and go to the local URI path and play mp3 file.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top