Page 1 of 1

Write permission to a file in the internal storage

Posted: Thu Mar 16, 2023 1:22 pm
by Cairoo
Dear forum,

I have two LiveCode apps on the same android device.
The first app creates a file in the internal storage's Documents folder, like so:

Code: Select all

set the umask to "000"
put "Test1" into url ("binfile:/sdcard/Documents/testfile.txt")
I've tested the above and the file is created.

I need the second app to modify this file.
I tried to do the following in the second app, but the file is not modified:

Code: Select all

put "Modified" into url ("binfile:/sdcard/Documents/testfile.txt")
What can I do to enable my second app to modify the file?

- Gerrie

Re: Write permission to a file in the internal storage

Posted: Thu Mar 16, 2023 1:33 pm
by Klaus
Hi Gerrie,

due to the strict security settings a.k.a. "Sandboxing" an app can only access files that have been created by that app.
We cannot access any data of another app!

Best

Klaus

Re: Write permission to a file in the internal storage

Posted: Thu Mar 16, 2023 2:26 pm
by Cairoo
Thank you, Klaus

I understand the sandboxing concept and why it's necessary, but that is already provided for in each app's own per-application documents folder, i.e. specialFolderPath("documents").

I actually need my two apps to share a single sqlite database and both should be able to insert new data.

Re: Write permission to a file in the internal storage

Posted: Thu Mar 16, 2023 2:35 pm
by Klaus
Cairoo wrote:
Thu Mar 16, 2023 2:26 pm
I understand the sandboxing concept and why it's necessary, but that is already provided for in each app's own per-application documents folder, i.e. specialFolderPath("documents").
That also applies to -> specialfolderpath("external documents")
Cairoo wrote:
Thu Mar 16, 2023 2:26 pm
I actually need my two apps to share a single sqlite database and both should be able to insert new data.
I understand that and would also like to do something like this, but I'm afraid this is just not possible.
Maybe someone will chime in and correct me if I'm wrong here.

Re: Write permission to a file in the internal storage

Posted: Thu Mar 16, 2023 6:30 pm
by jacque
https://support.google.com/googleplay/a ... 7955?hl=en
Google has tightened its privacy policy and only apps which fall into certain categories can access the public file system. This applies to apps like file managers, photo editors, etc. If your app wants to use this permission you need to fill out a form, and it must be vetted by Google and approved.

Besides that, LC does not currently support any access to the public file system. There's a feature request in the QCC for it but given Google's new restrictions I suspect it's low priority.

Re: Write permission to a file in the internal storage

Posted: Sun Apr 09, 2023 11:34 am
by Klaus
Find the report here and feel free to add some more comments:
https://quality.livecode.com/show_bug.cgi?id=23526

Re: Write permission to a file in the internal storage

Posted: Mon Apr 10, 2023 3:46 am
by FourthWorld
Do the two related apps need to be two separate apps? Could they be different views in one app?

Re: Write permission to a file in the internal storage

Posted: Mon Apr 10, 2023 4:31 am
by jacque
FourthWorld wrote:
Mon Apr 10, 2023 3:46 am
Do the two related apps need to be two separate apps? Could they be different views in one app?
We're looking for a way to import documents into an app. Currently we can't access any public-facing folders, which is where downloaded files automatically go. I'm not sure what you mean by a second app?

Re: Write permission to a file in the internal storage

Posted: Mon Apr 10, 2023 1:09 pm
by SteveB
Don't know if this will help your issue, but I did something similar a few years ago by using Dropbox to store an sql file.

Re: Write permission to a file in the internal storage

Posted: Tue Apr 11, 2023 4:15 pm
by FourthWorld
jacque wrote:
Mon Apr 10, 2023 4:31 am
I'm not sure what you mean by a second app?
Described in the opening line of this thread.