External Storage Plugin

This plugin allows you control manage file outside the app sandbox and into the phone

Limitations:

Only works Android and only handles external storage

Functions:

externalStorage.requestExternalStorage(listener)-- presents a popup where a users can grant app external storage access

listener(functions)(optional) returns callback event.status == "permission granted" or "permission denied"

externalStorage.hasAccessToExternalStorage()-- returns true or false if app has external storage access

externalStorage.getFile(pathExternal, pathCorona,shouldLookAtRoot)-- returns one of the following strings "could not find file", "could not save file", or "file saved". shouldLookAtRoot = should we look at base of device (default is false, true recommended for sd card

tranfer file to corona

pathExternal(string)-- where to get the file example "/test.txt"

pathCorona(path)-- where to export the file to, note system.pathForFile

shouldLookAtRoot(boolean)(optional)--(default is false) if set to true will check root instead of External Storage

externalStorage.copyFile(pathCorona, pathExternal, shouldLookAtRoot)-- returns one of the following strings "could not find file", "could not save file", or "file saved". shouldLookAtRoot = should we look at base of device (default is false, true recommended for sd card

tranfer file to external file

pathCorona(path)-- where to export the file to, note system.pathForFile

pathExternal(string)-- where to export the file to example "/folder1/test.txt"

shouldLookAtRoot(boolean)(optional)--(default is false) if set to true will check root instead of External Storage

externalStorage.deleteFile(pathExternal, shouldLookAtRoot)-- returns boolean true if deleted, false if not. shouldLookAtRoot = should we look at base of device (default is false, true recommended for sd card )

delete file in external storage

pathExternal(string)-- where to delete the file example "/test123.txt"

shouldLookAtRoot(boolean)(optional)--(default is false) if set to true will check root instead of External Storage

externalStorage.listFiles(pathExternal, shouldLookAtRoot)-- returns array of file paths, shouldLookAtRoot = should we look at base of device (default is false, true recommended for sd card )

list files in external storage

pathExternal(string)-- where to list the files example "/Music"

shouldLookAtRoot(boolean)(optional)--(default is false) if set to true will check root instead of External Storage

externalStorage.doesFileExist(pathExternal, shouldLookAtRoot)-- returns boolean true if file exists, false if not, shouldLookAtRoot = should we look at base of device (default is false, true recommended for sd card )

does file exist in external storage

pathExternal(string)-- where to check if file exists example "/dir/myFile.pdf"

shouldLookAtRoot(boolean)(optional)--(default is false) if set to true will check root instead of External Storage

externalStorage.makeFolder(pathExternal, shouldLookAtRoot)--

pathExternal(string)-- where to put the file and what to call the file "/newFolder"

externalStorage.isSdCardConnected()-- returns boolean, true if connected , false if not

externalStorage.sdCardPath()-- returns path of sd card to be used to copy, delete, get and list files with apis above

externalStorage.isSdCardWriteable()-- can you write to sd card (there may be restritions), returns boolean

externalStorage.totalSpace()-- returns mb(number) of data on phone

externalStorage.spaceAvailable()-- returns mb(number) of data free on phone

externalStorage.getExternalFilesDir(type)-- returns the absolute path to the directory on the primary shared/external storage device.

type(string) The type of files directory to return.

externalStorage.rename(pathExternal, newName,shouldLookAtRoot)

pathExternal(string)-- where is the file to rename

newName(string)-- what to name the new file

shouldLookAtRoot(boolean)(optional) if true, it will look at root

Properties:

the following return string that can be used in copy, delete, get and list files with apis above

  • externalStorage.dcim
  • externalStorage.download
  • externalStorage.movies
  • externalStorage.ringtones
  • externalStorage.podcasts
  • externalStorage.music

Support for Android 12

Please make sure your app requests Permission via externalStorage.requestExternalStorage(listener) and check with externalStorage.hasAccessToExternalStorage()

Build.settings

Helpful Links:

Get Plugin

Example

Support