Pradeep Simha
Pradeep Simha

Reputation: 18123

Checking disk space on cordova iOS

I am trying to check disk space available in mobile using below code:

cordova.exec(function(result) {
    var diskSizeInMB = result/1024;
    alert(diskSizeInMB)
}, function(error) {
    alert("Error: " + error);
}, "File", "getFreeDiskSpace", []);

In Android device it gives me correct result, whereas if I use iPhone/iPad it always returns me 0 as a output. Can anyone guide me how to resolve this issue? Or is there a way to check the disk size in iOS using cordova without writing custom plugin? To make this happen I haven't changed any configuration changes

Upvotes: 3

Views: 1403

Answers (1)

jcesarmobile
jcesarmobile

Reputation: 53301

It was a bug, but was fixed long time ago.

Old answer:

I confirm there is a bug on the code, the problem is getFreeDiskSpace is undocumented and cordova team want to remove the native code as getFreeDiskSpace isn't part of the w3c file API.

If you want to fix the bug for you app, go to CDVFile.m and change the line

NSNumber* pNumAvail = [self checkFreeDiskSpace:self.appDocsPath];

to

NSNumber* pNumAvail = [self checkFreeDiskSpace:self.rootDocsPath];

on the getFreeDiskSpace method

Upvotes: 3

Related Questions