-1

How do I check if an Excel file (.xlsx) exists on the SD card on Android using PhoneGap? If the file exits, how do I then import and export the file contents through javascript?

ElGavilan
  • 6,610
  • 16
  • 27
  • 36
Pavan Alapati
  • 267
  • 3
  • 5
  • 15
  • possible duplicate of [How to check a file's existence in phone directory with phonegap](http://stackoverflow.com/questions/10294166/how-to-check-a-files-existence-in-phone-directory-with-phonegap) – AtanuCSE Apr 02 '15 at 03:27

1 Answers1

0

First add the cordova File Plugin into your project.Then use the following code :

    var reader = new FileReader();
    var fileSource = <file path>;

    reader.onloadend = function(evt) {

        if(evt.target.result != null) {
            // If you receive not null value the file exists
        } else {
            // Otherwise the file doesn't exists
        }         
    };

    // We are going to check if the file exists
    reader.readAsDataURL(fileSource);   
Banik
  • 911
  • 6
  • 10