Pahlevi Fikri Auliya
Pahlevi Fikri Auliya

Reputation: 4567

How to get storage location in Cordova/PhoneGap?

I wish to store some application specific data (images & sound) which are downloaded during runtime. The download part has works correctly (using new FileTransfer();) but currently the target storage path is still hardcoded (i.e. file:///storage/emulated/0/myapp on my Genymotion simulator)

I believe the storage path is different among different devices, isn't it? If so, how to get the root path of the storage folder? I am not really particular about whether the folder is private or shared among different applications.

*I have checked https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md, but not really sure how to use the API.

I am using the latest Phonegap (3.4.0)

Upvotes: 1

Views: 1588

Answers (1)

jshbrntt
jshbrntt

Reputation: 5405

I believe you can use window.requestFileSystem for this.

https://developer.mozilla.org/en-US/docs/Web/API/LocalFileSystem

However, if you don't like the fact that it's effectively "dead" now use the FileSystem Cordova plugin instead.

https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md

Upvotes: 1

Related Questions