Questions

82 views
Skip to first unread message

GOOD

unread,
Apr 25, 2022, 3:18:22 PM4/25/22
to DroidScript
txt = app.ReadFile("/storage/emulated/0/options.txt");
Return: "", why? Permission, how create? 

Alan Hendry

unread,
Apr 25, 2022, 4:03:07 PM4/25/22
to DroidScript
HI,

In your previous post the file was read as
txt = app.ReadFile(app.GetAppPath()+"/options.txt");
using a relative path is preferable
txt = app.ReadFile("options.txt");

Writing files is not simple due to Android security and 
differences between running your app from DS and running from a built and installed app.
In my tests you can write to and read the following
app.GetPrivateFolder("data")+"/options.txt" // user cannot see file
app.GetSpecialFolder("Downloads")+"/options.txt" // user can see file;  use "Pictures" for images, "Music" for sound, "Movies" for video 
Regards, ah

GOOD

unread,
Apr 25, 2022, 4:06:05 PM4/25/22
to DroidScript
why the checkmark from "UI Material". object.setEnabled(false) - works as a dimming for the control and does not skip over it, it is active, but darkened.

понедельник, 25 апреля 2022 г. в 22:18:22 UTC+3, GOOD:

GOOD

unread,
Apr 25, 2022, 4:18:42 PM4/25/22
to DroidScript
var path = app.GetSpecialFolder("Downloads")+"/options.txt";//work
var path2 = app.GetPrivateFolder("data")+"/options.txt"; //work
txt = app.ReadFile(path2); //result ""
txt = app.ReadFile(path); //result ""
alert(txt);
Miui 11.
понедельник, 25 апреля 2022 г. в 23:06:05 UTC+3, GOOD:

GOOD

unread,
Apr 25, 2022, 4:21:50 PM4/25/22
to DroidScript
I need this particular file to be open to all users. it stores information about the recovery of the application.

понедельник, 25 апреля 2022 г. в 23:18:42 UTC+3, GOOD:

Alan Hendry

unread,
Apr 25, 2022, 4:40:01 PM4/25/22
to DroidScript
HI,
Normal processing is ..
In the Onstart check if save file exists, if it does then read it, else read initial file
var path2 = app.GetPrivateFolder("data")+"/options.txt";
if (app.FileExists(path2)) {txt = app.ReadFile(path2);} else {txt = app.ReadFile("options.txt");}
to save info for next run
app.WriteFile(path2,datatosave);
Regards, ah

GOOD

unread,
Apr 25, 2022, 8:56:12 PM4/25/22
to DroidScript
1) I only need to create, read, overwrite files in public folders where root is not needed and they are not hidden. all of the above codes work only with the root data folder, but it is not accessible to a regular user, so I want to create a file outside of these directories. 2) how to compare an empty text is clear, but it is not clear how to compare an empty text from "undefined" (it is considered empty)

понедельник, 25 апреля 2022 г. в 23:40:01 UTC+3, hendr...@gmail.com:

GOOD

unread,
Apr 25, 2022, 11:31:37 PM4/25/22
to DroidScript
how can I add a button in "absolute layout" and shift it to the right? on the example of "app bar" I can't set my button because there are problems with layers. they don't listen.

вторник, 26 апреля 2022 г. в 03:56:12 UTC+3, GOOD:

Alan Hendry

unread,
Apr 26, 2022, 8:40:50 AM4/26/22
to DroidScript
HI,

app.FileExists should tell you if the file exists before reading it.
To create an empty file you should use the empty string (two quotes) "" .
If you read a file and want to check if it's empty then compare to empty string 

You can have an absolute layout, then inside it add a (sub) layout Linear Right 
sublayout.SetPosition(0,yourtop, 1) // left 0, your top position 0 to 1, screen width) 
and put your controls inside the sub layout

You should be able to write and read GetPrivateFolder (user can't see it or update it)
and read and write to app.GetSpecialFolder("Downloads") (user can see and update it it probably at Internal > Downloads). 

Regards, ah
Reply all
Reply to author
Forward
0 new messages