September 18th, 2015, 09:23 AM
Android Memory Access
Hi everyone. I was wondering if someone might help. I am very new to Firemonkey programming for the Android platform. As soon as I try to do some IO operation to the memory of my android device I get a black screen on my android device and my application doesn't run. My application compiles without errors and I receive absolutely no error messages. I have tried two routes : 1.
The "AssignFile, Rewrite, Reset, Read, Write , CloseFile" way as well as the 2. TFilestream way to do memory operations. As soon as I do the IO Write my application doesn't work and only give me a black screen. Other android applications work well. Please someone help! Jacobus Opperman
September 18th, 2015, 09:55 AM
My guess is that you are attempting to write the file in a location you don't have write access to.
You can get the documents path like so
I wouldn't use the AssignFile/rewrite/reset/etc... method of writing/reading a file. Those methods have long been deprecated.
Also to "construct" the full file name of the file, use
you'll need to add System.IOUtils to your uses clause to find all TPath methods.
September 20th, 2015, 08:07 AM
Thank you Majlumbo for your reply. Thank you for introducing me to the TPath class - it is really a wonderful class!
Problem is solved! Apparently Assignfile/Rewrite/Reset/Read/Write/Closefile doesn't work for Android development. Also I made a mistake using the TFilestream method. For first time file creation I should have used PFileStream := TFileStream.Create(PPathAndFilenameCombined, fmCreate). I used fmOpenReadWrite. Thank you for your help! My program now executes on my Android device without any problems!