deleteFile

File

Deletes the specified file from the file system.

$m.deleteFile("offline_orders.txt", function(response) {

    var message;

    if(response.code == -1) {

           // External storage is not ready. Possible reason could be the storage

           // is mounted to file system on a computer.

           return;

    }

    if(response.result) {

        message  = "File deleted successfully.";

    } else {

        message = "Error deleting file. " + response.error.message;

    }

    $m.toast(message);

});

Syntax

        $m.deleteFile(filePath, fp_callback)

        $m.deleteFile(file, fp_callback)

Parameters

filePath

string (required)

The path of the file relative to the pack folder.

file

file (required)

The mowbly file object. Use getFile method to create the mowbly file object. The advantage of using file over filePath parameter is that file object provides options to specify the path relative to the application folder or storage root apart from pack.

fp_callback

function (optional)

Function that is invoked when the delete file operation is done. The function receives a response object as parameter with the following properties,

  1. code - {Number}. Possible codes are,
  1. -1 -  Storage is not ready.
  2. 1  - File path is successfully read.
  3. 0  - Error in reading file path.

                 

  1. result - {Boolean}. True, if the delete file operation is successful; false, otherwise.
  2. error - {Object}. Available when the code is 0. The error object contains,
  1. message - {String}. A short description of the error.
  2. description - {String}. A detailed description of the error.