Android : Finding path of physical external SD card in Android, Phonegap 3.5

on Sunday, October 12, 2014


My Phonegap application deals with some large files, so I want to store them on the user's external SD card if possible. The org.apache.cordova.file plugin says that you can call



window.resolveLocalFileSystemURL(
cordova.file.externalDataDirectory, ...)


which it describes as "where to put app-specific data files on external storage."


This resolves to file:///mnt/sdcard/Android/data/my.app.id and that's where my files get saved. Unfortunately, that's not "external" storage; a number of phones I have tested appear to have an "internal" SD card (built into the phone, limited capacity) and an external SD card (the pluggable slot).


With the Sony Xperia st23i, for example, the external SD card gets mounted at /mnt/ext_sdcard. Judging by pages like this one it's very device-specific where the physical external SD card appears on the system.


In this JIRA issue it was suggested that the file-system-roots plugin should provide a way to get at file:/storage/extSdCard, but the file-system-roots plugin is now supposed to be folded into org.apache.cordova.file; however, its documentation does not appear to have an option for the actual external SD card. ("External storage (SD card) " just means "not the phone's internal storage" rather than the pluggable slot.)


Is there a sensible, portable way to address the user-supplied microSD (if there is one) card from phonegap?


0 comments:

Post a Comment