Android Question Sharing files on Android

DoctorDebug

Member
Licensed User
Longtime User
Hi, I did see a lot written about accessing files in various places, but they seem at least a year old and I am hoping there is a good solution.

There is another system transferring files via ftp to the phone. My B4A app needs to pick those files up and transfer the relevant ones to another SFTP site. I have no control over the other application - it wants to save them in a folder right off of "internal storage" (but I might be able to redirect that to another location that it can access and write to).

I can find no common ground - a folder the other app can store to but I can access the files with B4A.

Not ever going to be a play store app, if that matters.

Thank you all.
 

drgottjr

Expert
Licensed User
Longtime User
There is another system

there was a movie about 50 years ago called
"colossus: the forbin project". colossus - a
supercomputer from that era - discovers on
its own that, "there is another system."

but i digress. as far as your problem is concerned,
i'm afraid i'm not following the flow.

it looks like you want to download resources from
an ftp site and then upload them to (another) sftp
site. at which point, apparently, someone with
another device will download them and store them
in file.dirinternal. i don't see how this other device
is any concern of yours.

the net library can download and upload files.
so, download the files from point A and upload them
to point B and send the other person a text
message informing them the files are ready.
is this not what you have described?
 
Upvote 0

DoctorDebug

Member
Licensed User
Longtime User
I am sorry if I was not clear. Let me try again.

There is an existing system that transfers files to an android. I cannot do much about that system. Those files, when they appear on the phone, need to have some processing and then sent to another system via FTP. I need to write a B4 App to do this - the FTP part is old hat for me. But the other app is saving those files to the internal directory (where the document, downloads, etc. of the phone are kept). I cannot figure how to get my new B4A app to access those files when they appear.

I hope that clears it a bit. I have used the info in older posts to try to give my app the permissions it needs to access that folder but none of them have to this point worked so I thought I would throw it out here to see if anyone has a better idea how to access those files.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
what do you mean by "internal" directory? are you talking about an app's file.dirinternal
folder? if that's the case, then the answer is: you can't access the files.

what i still don't get is if you uploaded these files, you already know all about them. you
downloaded them from point A and will upload them to point B. you have them yourself.

I cannot figure how to get my new B4A app to access those files when they appear.

you already have all the access to the files you want BEFORE they appear. what's the problem?
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
I am sorry if I was not clear. Let me try again.

There is an existing system that transfers files to an android. I cannot do much about that system. Those files, when they appear on the phone, need to have some processing and then sent to another system via FTP. I need to write a B4 App to do this - the FTP part is old hat for me. But the other app is saving those files to the internal directory (where the document, downloads, etc. of the phone are kept). I cannot figure how to get my new B4A app to access those files when they appear.

I hope that clears it a bit. I have used the info in older posts to try to give my app the permissions it needs to access that folder but none of them have to this point worked so I thought I would throw it out here to see if anyone has a better idea how to access those files.
The area where Documents, Downloads, etc are located on the device is actually referred to as Shared Storage (internal storage is generally understood to be the area reserved for app-specific files, is not accessible to other apps & is removed when the app is uninstalled). You can access files in shared storage, but you need to use a content provider - which means the user has to have some interaction with the process in the form of selecting the directory where the files are saved to / read from. Coincidentally, I have just finished an update to one of my apps where the backups are written to shared storage so that they are persistent in the event the app is uninstalled / reinstalled. I'd share the code with you, but it's written in Kotlin so it wouldn't do you any good.

To get started, you might want to look here -> https://developer.android.com/training/data-storage/shared/documents-files & then come back to the forum & search for relevant info.

- Colin.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

agraham

Expert
Licensed User
Longtime User
As it is not in the store if you target SDK28 then you can still use PERMISSION_WRITE_EXTERNAL_STORAGE to access most folders. Or if you target >= SDK30 you can use this permission
 
Upvote 0
Top