#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2015
    Posts
    6
    Rep Power
    0

    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
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    397
    Rep Power
    0
    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
    Code:
    TPath.GetDocumentsPath;
    or
    TPath.GetSharedDocumentsPath;
    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
    Code:
    TPath.Combine(TPath.GetDocumentsPath, 'filename');
    or
    TPath.Combine(TPath.GetSharedDocumentsPath, 'filename');
    you'll need to add System.IOUtils to your uses clause to find all TPath methods.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2015
    Posts
    6
    Rep Power
    0
    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!

IMN logo majestic logo threadwatch logo seochat tools logo