Save cumulative counter value to a flash/permanent storage

Beno you mentioned about save the value to the file area. How to do this?