Write and Read Tag

Is there a way of write and read Tags values with the SDK Module?
I want to add Scripting functions and, in one of the methods, I need to read and write Tags values.
It would be like using the method: system.tag.write(“TAG/value”,5), but with the SDK Module…

In your module hook, save the context. Then you can use context.getTagManager() to obtain the root of the SQLtags tree. Use the TagPathParser.parse() function to convert tag path strings into tag path objects, which can then be used to obtain a tag node from the tag manager. And then you can read and write using the tag node object.

Ok, I wrote the following code:
ContextManager context=ContextManager.getInstance();
SQLTagsManager tagManager=context.getContext().getTagManager();
TagPath tagPath = null;
try {
tagPath=TagPathParser.parse(path);
} catch (IOException ex) {
Logger.getLogger(Utilitario.class.getName()).log(Level.SEVERE, null, ex);
}
Tag tag=tagManager.getTag(tagPath);
tag.getValue().getValue();

But the Tag object has no method setValue
What I’m doing wrong?

Try adding this:

List<WriteRequest<TagPath>> writes = new ArrayList<WriteRequest<TagPath>>(1);
writes.add(new BasicWriteRequest<TagPath>(tagPath, value));
tagManager.write(writes, null, true);