Create audio file in my app folder


Hi, I use this code succesfully to record an audio note within an Android app:

import  { Media, MediaObject } from '@ionic-native/media';
import { File } from '@ionic-native/file';
  selector: 'page-modal-add',
  templateUrl: 'modal-add.html',
  providers: [ File ]
export class ModalAddPage {

  private activityForm: FormGroup;
  data: any;
  todayDate: string;

    public navParams: NavParams,
    private view: ViewController,
    private navCtrl: NavController,
    private formBuilder: FormBuilder,
    public database: DatabaseProvider,
    public alertCtrl: AlertController,
    private media: Media,
    private file: File
  ) {

  startRecordingAudio() {
    try {
      this.file.createDir(this.file.dataDirectory, 'Notes', false);

      const audioFile: MediaObject ='./audioFile.mp3');

      this.showAlert(audioFile, 'Info', 'Start recording!');
    catch (e) {
      this.showAlert(null, 'Error', 'Could not start recording.');


  showAlert(fileHandler, type, message) {
    let alert = this.alertCtrl.create({
      title: type,
      subTitle: message,
      buttons: [{
        text: 'Stop recording',
        handler: () => {



And it creates an audioFile.mp3 file at /storage/emulated/0 path.

I now need to create the file inside a


folder, not inside /storage/emulated/0 one as it does now.

I tried to use

const audioFile: MediaObject = this.file.dataDirectory + './audioFile.mp3');

with no luck (it creates a 3gp file with an arbitrary name, instead).

How can I accomplish it?

Thank you in advance.