Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Android
I am developing an application where i need to record user voice and save it into internal storage of the device,though i have gone-through many article but none of them are to the point
so please help me to achieve this,any help is appriciated.
below is the code i am using for recording user voice
 
private void startRecording() throws IllegalStateException, IOException{
            releaseRecorder();
 
            if(fileWithinMyDir.exists()){
                fileWithinMyDir.delete();
                }
 
            recorder = new MediaRecorder();
            recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
            recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
            recorder.setOutputFile(OUTPUT_FILE);--->//Here how can i give the path for sound files
            recorder.prepare();
            recorder.start();
           
        }
Posted 30-Apr-13 23:20pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

ok i have myself solved my problem after a little R&D and posting the solution here so that it could help somebody like me....
 
//getting path for storage
File audioFile = context.getCacheDir();
        OUTPUT_FILE =audioFile.getPath()+"/"+"myAudioFile.3gp";
 
//Function for Recoding Voice
	private void startRecording() throws IllegalStateException, IOException{ 
		
		recorder = new MediaRecorder();
		recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
		recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
		recorder.setOutputFile(OUTPUT_FILE);
		recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
 
        try {
        	recorder.prepare();
        } catch (IOException e) {
            Log.e("development", "prepare() failed");
        }
 
        recorder.start();
	}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,045
1 DamithSL 4,611
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 3 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100