views:

134

answers:

1

I would like to know what is the maximum length of a String when saving in the classic preferences System:

var prefs = Components.classes["@mozilla.org/preferences-service;1"]
                .getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref("com.exemple.namespace.preference", potentiallyLongString);

Couldn't find it in official documentation.

Note: I tried to type in more than 255, it works on Firefox 3.6, but I'm looking for a documented answer wich would certify that length L works since version V.

A: 

There's no documentation on that. You shouldn't store unreasonably large strings in prefs -- if you're not sure if it will be reasonable, it's likely not a pref.

Nickolay
Agreed, yet I'm wondering about an order of magnitude to know what's "reasonable" and what's not. E.g. if I want to store a short list of FQDNs, should I store the number and use individual preferences for the values or can I store them in a single string preference, separated by commas? If I'm agranteed I can store around 4K chars and the typical list is less than 10 domain names, I'd use the second which is simpler to implement…
streetpc
@streetpc: I don't think there's an actual limit in the order of thousands characters, and since the preferences system is quite stable there probably weren't many changes in the recent versions. So you could try it and use it.
Nickolay