Deploying and accessing local files on iOS and Android

Written by DavidI on Posted in UI

This tutorial shows you how to deploy and access files and/or folders containing files in your iOS and Android apps. To accomplish this, you create a new mobile app, a few lines of Object Pascal code, use the Project | Deployment menu item and use the System.IOUtils unit's TPath.GetDocumentsPath method and PathDelim in your code.

The steps to create the mobile app

1) use the File->New ->Mobile Application main menu item and select  the "Blank Application" project template.

2) On the form, add 1 TButton, 2 TLabel and 1 TImage components.

3) Double click on the TButton component to create the Button's OnClick event handler.

4) Add a "uses System.IOUtils;" just below the {$R *.fmx} in the implementation section.

5) Add the following Object Pascal code in the event handler to display the documents path and to load the bitmap from the documents folder:

procedure TForm1.Button1Click(Sender: TObject);
  DocPathLabel.Text := TPath.GetDocumentsPath;
  Image1.Bitmap.LoadFromFile(TPath.GetDocumentsPath + PathDelim + 'davidi_tiedye.jpg');

6) In the Project Manager, select each of the Android and iOS Target Platforms to active each one to build an application for each one.


7) Use the Project | Deployment menu item and select the Android and the iOS Device platforms and for each one click the "Add Files" button in the local toolbar to select the bitmap file to deploy with the app and set the Remote Path column value for each platform.

  • For Android, set the Remote Path to .\assets\internal
  • For iOS, set the Remote Path to StartUp\Documents

Here are screen shots of each of the resulting Deployment settings:


8) Compile, Deploy and Run the app for Android (I used my Samsung Galaxy S4) and iOS (I used my iPhone 4s)

You can read additional information about mobile application development and deployment on the Appmethod DocWiki using the following URLs:

Tags: Appmethod iOS Android Multi-Device Object Pascal Deployment

Gold User, Rank: 1, Points: 2466
David Intersimone (known to many as David I.) is a passionate and innovative software industry veteran-often referred to as a developer icon-who extols and educates the world on Embarcadero developer tools. He shares his visions as an active member of the industry speaking circuit and is tapped as an expert source by the media. He is a long-standing champion of architects, developers and database professionals and works to ensure that their needs are folded into Embarcadero's strategic product plans. David holds a bachelor's degree in computer science from California Polytechnic State University at San Luis Obispo, California.

Check out more tips and tricks in this development video: