VilleK wrote:It turns out that string array writing was never implemented. I added that now
Thanks, Ville! It works perfectly.
Kjell wrote:Not sure why you'd want to use "char" encoding for a paint program
Yeah, I started from the FileDemo and got a bit lost in the loops trying to detect the letter A

Thanks for your great and simple example!
It also confirms a bug I found while testing: the FileName path behaves differently depending on the target platform.
For Android compatibility, I put Paint.dat file in the "assets" folder, and renamed it to paint.txt so I could easily view it on the phone.
I also added a Timer to save the file every 5 seconds, since I don't think OnClose is called when the app shuts down on Android.
I tested /assets/ since ZgePlatform_Android expects that to access files inside the APK. But the Help documentation says:
FileName
The name of the file that will be opened, in a path relative to the current project. Examples: "Data.txt", "levels\Level".
So I tried both styles, with different results:
Preview mode
assets/paint.txt OK
/assets/paint.txt NOT WORKING
This is problematic for cross-platform compatibility, since Android expects /assets/.
Windows exe
assets/paint.txt OK
/assets/paint.txt OK
Linux
assets/paint.txt OK
/assets/paint.txt OK
Android
assets/paint.txt NOT WORKING
Expected, since Android uses "/assets/" to read from inside the APK
If I manually use Android Studio to create the "assets" folder in
/data/user/0/com.mydomain.paint/files/assets/paint.txt
it works for both reading and writing.
/assets/paint.txt OK but not for writing (which is expected since the file is read-only inside the APK)
I suppose the decision to require the path to start with /assets/ on Android is to avoid accidentally loading a file whose name just starts with "assets". In that case, Preview mode should also support /assets/paint.txt.
VilleK wrote:I think as long as we change the data path to a path that has read/write access then it should be fine.
Then I can simply replace dataPath with extPath. They are almost the same, but extPath points to a location the user can access, making it more suitable for placing custom user files.