Firefox Extension Development - Data Storage - is Firefox Preferences a good place?

后端 未结 2 1938
余生分开走
余生分开走 2021-01-03 10:54

I have developed a Firefox add-on that needs to save some user-data in the local machine. Right now, I use the filesystem functionality that Firefox provides to create some

2条回答
  •  长发绾君心
    2021-01-03 11:29

    With newer versions of Firefox you can use SQLite to store data. The SQLite API in JavaScript isn't terribly good, but from Firefox 3.6 it's starting to get pretty solid (asynch fetching of data, binding multiple sets of data, etc).

    You can open/create a file in the profile directory using the following code. It works on all platforms Firefox runs on:

    var file = Components.classes["@mozilla.org/file/directory_service;1"]
                         .getService(Components.interfaces.nsIProperties)
                         .get("ProfD", Components.interfaces.nsIFile);
    file.append("my_db_file_name.sqlite");
    

提交回复
热议问题