Jump to content
jiyiwan

I can't deploy my local files to the public directory of my phone, what's wrong?

Recommended Posts

I am developing an Android app and I want to deploy a local file to the public directory of my phone. I have done the following and tried many times, but I am unable to deploy the file to my phone. What is the problem? Could any of you help me?
1. Select the compilation configuration and target platform: select "Debug configration - Android 64-bit platform" in Project > Deployment
2、Add the line for deploying images: In project>Demplyment, click the "add files" button, the parameters are as follows
local path=mypic\ 
Local Name=pic.jpg
Type=File
remote path={sdcard}\Download\MyBrain\mypic\   
remote name=pic.jpg
I don't feel like there's anything wrong with it, but I just can't deploy this image to my phone. What is the problem?
 

微信截图_20230602104107.png

Share this post


Link to post
27 minutes ago, jiyiwan said:

What is the problem?

You cannot deploy a file using Deployment Manager to a folder outside of the application. It might help to know why you actually want to, as there are issues inherent with dealing with "public" folders, especially on later versions of Android. 

  • Thanks 1

Share this post


Link to post

Here's what I was thinking: if the apk installer could deploy the local documentation to a public directory, it would make it easier for me to manually modify them later in the phone.

Share this post


Link to post
20 minutes ago, Dave Nottage said:

You cannot deploy a file using Deployment Manager to a folder outside of the application. It might help to know why you actually want to, as there are issues inherent with dealing with "public" folders, especially on later versions of Android. 

Here's what I was thinking: if the apk installer could deploy the local documentation to a public directory, it would make it easier for me to manually modify them later in the phone.

Share this post


Link to post

@jiyiwan

 

Starting with Android 11, things will be even more restricted for Android developers, not just in Delphi! But not, unfortunately, for hackers! Is not it?

by default you can read/write in sub-folders of the app!

 

Using ADB (Android tools) it is possible to do some magic to overcome some barriers, however, it is necessary to master the tool and issue some line commands to your device, either via USB or Wifi!!! Nothing too easy around here!

 

On the other hand, you could do it like this:

  • Deploy your files etc... to the default folder used by Delphi for Android devices: assets\internal (or external if you have privileges)
  • after the first run of your app, check and copy the desired files to other folders on the device (unfortunately, this is not possible by default, so your app needs a special permission)
    • To get the special permission, you must necessarily ask the device user to grant it! The proposed permission is "Access all files" (MANAGE_ALL_FILES_ACCESS_PERMISSION), however this permission requires you to ask Google-Play for permission to grant it, if you distribute your application through this means! *you need add just a permission in your Android Manifest, see in your Project-Options->Permissions the list of permissions for this!
    • This permission is easily implemented in the app, and works to access all folders on the Android device, with the exception of some system folders, such as: Android/Data and some other control ones!
    • After getting the permission "MANAGE_ALL_FILES_ACCESS_PERMISSION" (user can revoke it), you will be able to read and write in practically all the folders of the device (with the exception of some of the system), then, you will be able to read, write, copy, delete your files. This way, your own application can move the files that were deployed to another folder, and then just use them.

I can confirm that the special permission "MANAGE_ALL_FILES_ACCESS_PERMISSION" really works, however, Goggle requires you to send a request reporting "why do you need this permission in your software?", if you want to distribute your application via Google-Play, for example! *this permission is only used by Antivirus, Manager Files, etc...

Edited by programmerdelphi2k
  • Thanks 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×