[Dev] Platform Storage

McGee, Art amcgee7 at jaguarlandrover.com
Thu May 22 14:57:39 GMT 2014


I'm working on an app that stores and reads from the Downloads directory on
the system using.  I seem to having an error when trying to access that
storage location.  This seems to be a change from EOY release and the APR22
release.   Please advise if I'm using this incorrectly or if something has
changed in the security model.

Thanks,

Art

It asks for permission using the config.xml file with the following.
<tizen:privilege name="http://tizen.org/privilege/filesystem.read" />
<tizen:privilege name="http://tizen.org/privilege/filesystem.write" />

The code that seems to have the fault.
        if (typeof(tizen) !== 'undefined') {
            *// Has this called changed or should I be
requesting permission by another means? Note this._settingsStorageName =
"downloads"*
            tizen.filesystem.resolve(this._settingsStorageName,
function(directory) {
                var settingsFile;
                try {
                     settingsFile =
directory.resolve(self._settingsFileName);
                } catch(ex) {
                    console.warn("Settings file doesn't exist, creating
...", ex);
                    settingsFile =
directory.createFile(self._settingsFileName);
                }

                settingsFile.readAsText(function(contents) {
                    //console.log("Settings file contents", contents);
                    var configValues = null;

                    if (contents.length > 0) {
                        try {
                            configValues = JSON.parse(contents);
                        }
                        catch (ex) {
                            console.error("Error occured during parsing
settings file", ex);
                            aCallback(ex);
                        }
                    }

                    if (!configValues || !configValues.version ||
configValues.version < self._values.version) {
                        configValues = jQuery.extend({}, self._values);
                        self.save();
                    }
                    //console.log("Loaded settings:", configValues);

                    if (JSON.stringify(configValues) !==
JSON.stringify(self._values)) {
                        console.log("Settings updated.");
                        self._values = configValues;
                        self._callListeners();
                    }

                    aCallback();
                }, function(ex) {
                    console.error("Cannot read settings file", ex);
                    aCallback(ex);
                });
            }, function(error) {

                console.error("Error occured during opening Documents
directory", error); *// This is the line that reports the error.*
                aCallback(error);
            }, "rw");
        } else {
            console.warn("Tizen API is not available, cannot read settings
from persistent storage.");
            aCallback();
        }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.tizen.org/pipermail/dev/attachments/20140522/baa48d66/attachment.html>


More information about the Dev mailing list