thefoyer
thefoyer

Reputation: 314

reading/writing preferences

I have read most all of the documentation and questions related to preferences I could find but I have an error that is always coming up no matter what method I try and I do not understand it.

js file loaded in browser overlay xul

var prefs = Components.classes["@mozilla.org/preferences-service;1"].
                getService(Components.interfaces.nsIPrefService).
                getBranch("extensions.{my-guid-id}.");

var value = prefs.getBoolPref("firstrun");

defaults/preferences/prefs.js:

pref("extensions.{my-guid-id}.firstrun", true);

The error message in the error console says uncaught exception: "compenent returned failure code 0x8000ffff" on line 27 which is right at getBoolPref() call.

Upvotes: 0

Views: 271

Answers (1)

Mike Kaply
Mike Kaply

Reputation: 745

Your code looks correct.

Are you sure that you did not put the word true in quotes or accidentally already set it as a non boolean preferences?

I would suggest going into about:config and verifying that your firstrun preference is showing up as a Boolean.

That's the most common cause of the problem you are seeing.

Upvotes: 1

Related Questions