I am using an external .txt file to save the incrementing name index for whenever someone "takes a picture" in my app ( i.e. image_1.jpg, image_2.jpg etc...). I am trying to save the data externally so that a user does no overwrite their pictures each time they run the program. However, because of the way that Processing packages its contents for export I cannot both read and write to the same file. It reads the appropriate file located in the apps package contents, however, when It tries to write to it it creates a new folder in the same directory as the app itself and writes a new file with the duplicate name to the one it is trying to read/write to.
Essentially, it reads the proper file but refuses to write to it, instead making a copy and writing to that one. The app runs fine but every time you open it and take pictures you overwrite the images you already had. I have tried naming the "write to" location the explicitly same link as where the exported app stores the data folder inside the package contents (Contents/Resources/Java/data/assets) but this creates a copy of this directory in the same file as the app. I have also tried excluding the file I am trying to read/write from my data folder when I export the app by changing the read code to "../storage/pictureNumber.txt" and then putting this file next to app itself. When I do this the app doesn't launch at all because it is looking in its own data folder for storage and refuses to go outside of itself with ../ . Has anyone had luck both reading from and writing to the same file in an exported processing .app?
Here is the code for the class that is handling the loading and saving of the file: