Android Question Application for Android(14) SDK: 34

Sergey_New

Well-Known Member
Licensed User
Longtime User
As I understand, in this case the app can't access the Download folder.
For the app to work, the user must place their files in this folder.
How to avoid violating Google's requirements?
It's strange that the device's file manager has access to the Download folder.
I need to copy files from there to the folder created by the app.
 

DonManfred

Expert
Licensed User
Longtime User
How to avoid violating Google's requirements?
Simple. Do not publish Apps :D
Sorry, i couldn´t resist.

The Access to the Downloadsfolder is Restricted.
You can access the files using ContentChooser but not directly. Search the forum for examples on how to use ContentChooser
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Simple. Do not publish Apps :D
Why does the device's file manager have access to the Download folder?
Tried using ContentChooser, but the app was rejected in AppGallery and RuStore.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Why does the device's file manager have access to the Download folder?
Tried using ContentChooser, but the app was rejected in AppGallery and RuStore.
because it is a direct user permission and cannot be tampered with. So it has administrator permissions
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
If you need to save text files you can do it, I just have to change the mime type. If you need to read files it's another thing.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
If you need to read files it's another thing.
I need to copy text files from the Download folder to a folder created by the application in DirInternal and then read them. The user does not have access to this folder to put files from Download there himself. Right?
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
You should do a test. In fact, everything that is linked by Mediastore (audio/images/video) is possible to read and write it. I also managed to write the text, Json and more, I didn't try to read it.

At the moment I can't do a test, you should make attempts on the basis of the code I shared.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
I did some tests, it is not possible to have the list of files in the download folder.
It is not possible to read a file in the download folder whose name is known
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
It is not possible to read a file in the download folder whose name is known
I didn't understand this phrase. Can a file whose name is unknown be read?
So it has administrator permissions
Probably because it is a Systemapp.
There are file managers on Google Play that can be installed on any device. And they have access to its folders. Why do they get administrator rights or become system ones?
 
Upvote 0

Mehrzad238

Active Member
In addition to media files, I need to copy text files. Is this possible?
If you need to copy and access a file, you go this way, but I'm not sure exactly what you want!

you can create a folder in path ===>> Internal storage > Android > Data >application packagename by using this line

B4X:
rp.CheckAndRequest(rp.GetSafeDirDefaultExternal("name a folder"))

And by using ContentChooser, you can copy anything on that path and, like below

B4X:
Dim Path As String=rp.GetSafeDirDefaultExternal("your folder name")
File.Copy(Dir,FileName,Path ,"anyname with any format will do the job")

By just using Path, you can access your file for anything, but you have to do it manually🤷‍♂️
 
Upvote 0

Mehrzad238

Active Member
I need to copy text files from the Download folder to a folder created by the application in DirInternal and then read them
If you need this, my code will do the job, but you have to do it manually.
If you want it to be done automatically, that is another story.

So, if your text comes from your host, just download and save it on this path.
B4X:
rp.CheckAndRequest(rp.GetSafeDirDefaultExternal("name a folder"))

After that, practically you can do anything with that file.

But from the download folder, the user must choose that.
Which you have to copy on the Path that you created. After that, practically you can do anything with that file.

Let me explain what exactly I am proposing here:

So you choose your file from internal storage with this code and copy that in your folder that is accessable:

B4X:
cc.Show("*/*", "choose a file")
Wait For cc_Result (Success As Boolean, Dir As String, FileName As String)
Dim Path As String=rp.GetSafeDirDefaultExternal("your folder name")
File.Copy(Dir,FileName,Path ,"anyname with any format will do the job")

This was for manually for automatically I believe is even easier with OkHttpJob2

Just before doing anything of this use RuntimePermissions to create Path so be existed(I use it when I want to get notification PERMISSION from user)
 
Upvote 0
Top