I want to record an audio from user and want to store it on internal memory where my application is installed.
To access this path I am using
This gives path something like /data/data/<packagename>/files
I append file name in path and set the path while recording.
And also passing the same path while playing the recorded voice.
It gives error in mediaplayer's prepare method.
Let me make a note that if I give path "/sdcard/<filename>" everything works perfect.
But it does not work when I use
thanks a lot for your reply.
Yes I agree that it is advisable to store audio files on external memory.
But requirement forces me to do in internal memory only.
So can you tell me why android is not allowing me to create files in
/data/data/<my package>/files/<myfile.3gp> ?
I am using the above code.
1. Call openFileOutput() with the name of the file and the operating mode. This returns a FileOutputStream.
2. Write to the file with write().
3. Close the stream with close().
Easy does it, let the system figure out where to put the file.
Misha van Tol wrote:Why are you using a hard-coded path?
Thank you again Misha,
I am not using the hardcoded path.The path which I gave above is taken from the logs.
I am fetching the path this way..
I would go for the FileOutputStream but I want to know that if above code works for sdcard path why it is not working for the above given path.
Hardik Trivedi wrote:I want to write file in Internal Memory. I am confused why should use above permisssion in my manifest file.
Can you explain.
Several posters recommended that you use external memory, such as on an SD card, so this was in addition to what they suggested. I find that too much Android-related help shows code examples and omits mentioning the necessary permissions.
Peter Johnson wrote:
Hardik Trivedi wrote:I find that too much Android-related help shows code examples and omits mentioning the necessary permissions.
Yup very true,
But right now I am concentrating to use internal memory only.
Now I am using file descriptor to record and play the sound.
In my application further I weant to use this sound file as a notification sound.I tried to assign notification.sound variable but it accepts only path in string form. So again same problem is arised.
I record the file using file descriptor and using below line to assign path in notification.sound
This line is also returining the same path.And mediaplayer.prepare() method fails for this path.
This is now proving hair raising for me.
Please get me out of this situation.