Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
Delphi

Delphi XE5 – deploying and accessing local files on iOS and Android

Larry in Canada recently sent me an email asking a Delphi XE5 mobile multi-device question: “How do you include files and/or folders containing files with a Delphi Android application APK file?” I told him I would create a simple example and explain how to deploy a file with your application and then access it from a Delphi app for iOS and Android. To accomplish this, you create a new mobile app, write one or more lines of code, the Project | Deployment menu item, and use the System.IOUtils unit’s TPath.GetDocumentsPath method and PathDelim in your code.

The steps I followed to create my sample mobile app

1) File | New | FireMonkey Mobile Application – Delphi and used the “Blank Application” project template.

2) On the form, I added 1 TButton, 2 TLabel, and 1 TImage component.

3) I double clicked on the TButton component to create the OnClick event handler.

4) I added a “uses System.IOUtils;” just below the {$R *.fmx} in the implementation section.

5) I added the following code in the event handler to display the documents path and to load the bitmap from the documents folder:

 

 

6) In the Project Manager, I added Android and iOS Target Platforms so that I can build for each of the two platforms.

projectmanager_5f00_10030_2d00_285x300-3021838

7) Using the Project | Deployment menu item, I chose the Android and the iOS Device platforms and for each one I clicked on the “Add Files” button in the local toolbar to select the bitmap file I want to deploy with my app and set the Remote Path column value:

    • For Android, set the Remote Path to

assetsinternal

    • For iOS, set the Remote Path to

StartUpDocuments

Here are screenshots of each of the resulting deployment settings:

projectdeploymentandroid_5f00_10033_2d00_300x96-4526088

projectdeploymentios_5f00_10036_2d00_300x112-1629271

7) Compile, Deploy and Run the app on Android (I used my Samsung Galaxy S4) and iOS (I used my iPhone 4s) producing the following result when I click on the Button:

androidscreencapture_5f00_10039_2d00_171x300-9562000 iosscreencapture_5f00_10042_2d00_200x300-3508433

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

 

Do you want to create an app for iOS, and Android? Try the Cross-Platform Development tool, which can help you create apps in the Delphi or C++ environments.
Try it out and make the most of it. Request a Product Demo here.
Kai 1.1 Now Available! Kai 1.1 Now Available! What's Coming in RAD Studio 13.2 Florence

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.

Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES