user2169268
user2169268

Reputation:

Phonegap LocalFileSystem on Android uses External Storage instead of Internal Storage

In our Application, the User is able to Download PDF´s and open it via InAppBrowser on iOS or local PDF Reader on Android. To store the Files we use the LocalFileSystem option from Phonegap. It works well, but the Problem is, the Files are stored in the External Storage on Android. This causes some Issues. First, the Files are accessable for the User and second, when I delete the Application, the Files are still persistant. I don´t understand why Phonegap is not using the Internal Storage to make it similar to iOS.

So here is my Question: Is there a way to Store Files in the Internal Storage with Phonegap, do I miss something obvious, or do I have to write my own PlugIn to store Files in the Internal Storage?

Note:

Upvotes: 2

Views: 7413

Answers (2)

user2169268
user2169268

Reputation:

The Phonegap Documentation doesn´t really go in Detail in general. Here is some Information I would like to add to the LocalFileSystem Documentation: http://docs.phonegap.com/en/2.6.0/cordova_file_file.md.html#LocalFileSystem

LocalFileSystem.Persistant:

  • Android: Uses external Storage. Files saved to the external Storage are world-readable and can be modified or deleted by the user. On removingApplication, the Files are still persistant. Source: http://developer.android.com/guide/topics/data/data-storage.html#filesExternal
  • iOS: LocalFileSystem.Persistant uses an App specific Internal Storage. Files can not be modified or deleted by the User.

LocalFileSystem.Temporary:

  • Android: Uses external Cache Directory. Files saved to the external Storage are world-readable and can be modified or deleted by the user. **If the user uninstalls your application, these files will be automatically deleted.
  • iOS: Same behavior like Persistant.

Summary: I still have no Idea why Phonegap is not using Internal Storage to make it similar to iOS. But, since I haven´t noticed any differences between Persistant and Temporary on IOS and the Files are getting deleted on uninstalling Application on Android, I would suggest to always take LocalFileSystem.Temporary.

Update: In iOS if you don't use persistent, your data can be deleted by the OS in cases of low memory

Do you agree with that?

Thanks and sorry for my bad English :)

Upvotes: 2

Edward van Raak
Edward van Raak

Reputation: 4920

On Android, the method

window.requestFileSystem

will check if there is an SD card available on the device. If there is, your root directory will be the SD card. If there isn't it will use

/data/data/{app package name}

I think you need to specify the root directory on Android so it doesn't use the SD card by default.

This blog might be useful for you.

Upvotes: 2

Related Questions