Saving the output of detected objects in file, in android

I would like to save the output of detected objects in a .txt (or any kind of a file) in my android phone.
It should be like that whenever I detect some objects, they are saved in a file in android, what would be the best aproach to resolving this issue ?
For example, whenever it detects 15 objects, it saves the output of those 15 objects in a file, in android phone.