This is a library/sample of using cordova and cordova-plugin-files to access/scan sdcard/external-storage in Android
Switch branches/tags
Nothing to show
Clone or download
Latest commit 0915da4 Dec 20, 2015
Failed to load latest commit information.
FullExampleProject example project Dec 21, 2015 Update Dec 20, 2015
exernalStorageSdcardAccess.js API Dec 20, 2015


Android SDcard & External Storage access API

This is a sample API of using cordova-plugin-files to scan sdcard & external-storage in Android

Example of using the API:

new ExternalStorageSdcardAccess( fileHandler ).scanPath( "file:///storage/sdcard1/music" );
function fileHandler( fileEntry ) {
    console.log( + " | " + fileEntry.toURL() );


<script src="js/exernalStorageSdcardAccess.js"></script>
  • config.xml
delete: <preference name="AndroidExtraFilesystems"/>
  • make sure testing environment can access it's own external storage at the time of testing. ( e.p. if the device is connected with usb, make sure it is connected as a camera; Call the APIs after recieving the "deviceready" event )


ExternalStorageSdcardAccess( _fileHandler, _errorHandler ):
Create a new instance of this class to use the API.Both parameters have default handler.
@params _fileHandler(fileEntry): when a file is discovered, the handler will be called, pass a FileEntry object
@params _errorHandler(error): when a error occurs, the handler will be called, pass a FileError object

Scan all the files by using all the pathes in the array

ExternalStorageSdcardAccess.scanPathList( arrayOfPath ):
Scan all the files and directories from the root

ExternalStorageSdcardAccess.scanPath( path ):
Scan all the files by using the path

Things need to know before looking into the source code


About correct path parameter

"cdvfile://localhost/",                 // * Err 5 (wrong pattern)
"file:///",                             // * root, directoryEntry
"file:///somefile/",                    // * somefile, directoryEntry
"file:///somefile",                     // * somefile, directoryEntry
"file:///randomdumbname",               // * Err 1, (not found)
"file:///somefile/ACG/aaaaa.mp3",       // * OK, fileEntry