Software Archive
Read-only legacy content
17061 Discussions

No way to save a file on android, in a public folder, which you can see on a PC for example!

Sebastian_G_2
Beginner
365 Views
cordova.file.dataDirectory is undefined

 

Is there a working example, where you take a picture, and move it into A PUBLIC FOLDER?

I tried for hours now, and all recommended ways of doing this will not work. I use the newest Versions only (XDK, File-Plugin, CLI)

 

So this link does not help, since the File Plugin does not seem to work as desribed:

https://www.npmjs.com/package/cordova-plugin-file#where-to-store-files

 

This solution works, if you are fine with private files, that can only be seen from within your app:

http://stackoverflow.com/questions/10335563/capturing-and-storing-a-picture-taken-with-the-camera-into-a-local-database-ph

0 Kudos
3 Replies
PaulF_IntelCorp
Employee
365 Views

Saving files to a mobile OS device's filesystem is much different than using a PC. Most of the filesystem in a mobile OS device is protected and off-limits to your app. This is a feature of the mobile OS which insures security and stability. It is not something that the XDK enables or disables, it is a device OS limitation.

The Cordova file plugin is difficult to use and has gone through multiple changes. I recommend you start with this article > http://www.html5rocks.com/en/tutorials/file/filesystem/ and see this Cordova article > http://cordova.apache.org/docs/en/dev/cordova/storage/storage.html and this Android article > http://developer.android.com/guide/topics/data/data-storage.html

You might search the Cordova registry for alternatives to the core Cordova plugin, as well > http://cordova.apache.org/plugins/?q=file

0 Kudos
Sebastian_G_2
Beginner
365 Views

I use the private App storage now, as I see the point of these limitations now ;)

However, is there a way, to make data more persistent if an app needs to be used in a business context?

Right now, somebody could just delete the stored App Data in the Settings of the Phone or Tab. Of course collected data is supposed to be sent to a server anyways as soon as the device is online...but if the device is in offline mode, and/or gets used by different users, there might be situations... ;)

In my opinion, the OS developers should not focus on personal use so much and also keep business and automation needs in mind..., but yeah, you are right, there is probably not much XDK-developers can do about it.

Thanks a lot for your reply!

Best, Sebastian

0 Kudos
PaulF_IntelCorp
Employee
365 Views

Sebastian -- there are a few native local storage plugins out there that do what you are looking for. The most popular is the SQLite plugin, but if you search the cordova plugin registry for native local storage you might find something that better suits your needs.

0 Kudos
Reply