Read/Write issue of Non-Volatile Storage (NVS)

I am working on a project using ncs 2.2.0 on the nRF52833DK.

I have a very simple requirement, which is to save an id-data pair in Non-Volatile Storage and be able to change the corresponding data at any time.

I can find some related cases, but they all seem quite old and unable to solve my problem. For example, I may need to include many libraries, such as:

#include <zephyr.h>
#include <device.h>
#include <drivers/flash.h>
#include <fs/nvs.h>
#include <logging/log.h>

However, zephyr.h has been deprecated and replaced with <zephyr/kernel.h>. The same goes for device.h and others. None of the libraries can be properly included in my project, which is just a sample in ncs.

I read the documentation for Non-Volatile Storage (NVS) in Zephyr, but I still don't quite understand how to implement it correctly in my ncs project.

Is there a more recent sample that demonstrates how to read and write an id-data pair in ncs? Or is there a more up-to-date tutorial or guide to help me accomplish this task?

I just need to read and write an id-data pair, where the data value is only 0 or 1. I believe this should be a relatively easy thing to accomplish. I'm new to this, so if I have any naive views, please instruct me.

Thank you.

Related