SMS/MMS data location on Android, Cordova/PhoneGap, Cordova-Plugin-File

201 views Asked by At

I'm creating a Cordova app and I'm using their file plugin to access files within the system. the problem is, it doesn't seem to recognize the file.

One thing I know is different android versions have different locations for messages, according to source, my emulator which that runs Android version 13 should have the messages located here: /data/user_de/0/com.android.providers.telephony/databases/mmssms.db. According to source1 /data is one of the root folders on the android system.

Assume this code is within on device ready:

    function success(fileEntry)
    {
        fileEntry.file(function(file) {
            var reader = new FileReader();
            reader.onloadend = function(e) {
                var content = this.result;
                alert(content);
        };
            reader.readAsText(file);
        });
    }

    function fail(e)
    {
        alert('failed to locate file: ',e);
    }
    window.resolveLocalFileSystemURL('/data/user_de/0/com.android.providers.telephony/databases/mmssms.db',success, fail);

When emulating, it runs the fail callback function.

So my question is, what am I doing wrong? I'm not well read on Cordova and the help would be greatly appreciated!

1

There are 1 answers

1
Eric On

It's because you can't have access to that directory. Read the documentation to know which folders you have access to and resolve the path.