Shad81
Shad81

Reputation: 1

How to use the SD card when recording audio using PhoneGap Media startRecord?

I'm trying to create a recording app that will record audio using the smartphone microphone. Currently I'm developing for Android. I'm using the following code:

var audioRec;
var src = "fileName.wav";
audioRec = new Media(src, onSuccess, onError);
audioRec.startRecord();
// some code
audioRec.stopRecord();

The app is recording to the root directory in the internal storage.

If I create a directory - for example: recordingApp and change src to:

var src = "recordingApp\fileName.wav";

Then the app records to the directory "recordingApp" under root in the internal storage.

How do I record to a directory in the SD card external storage?. For example, the directory "recordingApp" in the SD card.

Upvotes: 0

Views: 114

Answers (1)

Brad L.
Brad L.

Reputation: 1029

It depends... Some versions of Android mount the external card in different directories (you also need to handle when there is no SD card present). Sometimes it is /storage/extSdCard other times /sdcard

You can use the file plugin's built in enums to get the right directory in most cases: https://github.com/apache/cordova-plugin-file

For Android you would generally want cordova.file.externalApplicationStorageDirectory

Upvotes: 0

Related Questions