location of library folder

library_index.json and package_index.json are both located in ....Appdata\local\arduino15, but all library files in Program files (x86)\Arduino\libraries

If you update Arduino you must remember to save changed .h and .cpp to another folder and then copy them back.

You can change location of your sketches.

Why cannot library files be in ....Appdata\local\arduino15\libraries or a folder specified in preferences.txt?

(Another way would be to program the installer to save the files before updating and then move them back)

kgb10a8: but all library files in Program files (x86)\Arduino\libraries

The only libraries that should be in that location are the ones that come with the Arduino IDE installation, which of course will be updated along with the update. You should never put anything else in the Arduino IDE installation folder (e.g., "Program files (x86)\Arduino\libraries"). Instead, put your libraries in {sketchbook folder}\libraries, where {sketchbook folder} is the location defined in the Arduino IDE's File > Preferences > Sketchbook location preference. Updating the Arduino IDE does not affect the sketchbook folder, so the things you save there persist through an update.

kgb10a8: If you update Arduino you must remember to save changed .h and .cpp to another folder and then copy them back.

As long as you make sure to refrain from putting things in the Arduino IDE installation folder (despite some bad advice you will occasionally find on the Internet), you never need to do that.

kgb10a8: Why cannot library files be in ....Appdata\local\arduino15\libraries or a folder specified in preferences.txt?

As you now know, they can!

kgb10a8: (Another way would be to program the installer to save the files before updating and then move them back)

Not necessary if people just use the Arduino IDE in the way it was designed to be used.