Saving a files on Android

Please post anything related to the Hollywood APK Compiler here
Pierre55
Posts: 54
Joined: Sat Apr 01, 2017 4:25 pm

Saving a files on Android

Post by Pierre55 »

Hi,

I succeed to upload my application to my Android device (Galaxy Tab S2) but now I have another problem with the SAVING section of my script, when I want to save I don't have any way to choose the destination and the one the script propose is not working (/storage/emulated/0!), it give me an error "Error Locking /storage... in function FileRequest"

Thank you.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Saving a files on Android

Post by airsoftsoftwair »

On Android you may only write to certain folders. You can get those paths using GetSystemInfo(). You can choose to write to "InternalStorage", "ExternalStorage", or "SDCard", e.g.

Code: Select all

StringToFile("Hello World", FullPath(GetSystemInfo().InternalStorage, "test.txt"))
Pierre55
Posts: 54
Joined: Sat Apr 01, 2017 4:25 pm

Re: Saving a files on Android

Post by Pierre55 »

Thank you,

I need more info about this command..

I try;

t = GetSystemInfo()
DebugPrint(t)

and I have this;
Table: 0x5a676ca8

It seems that this command can work only on Windows, MacOS, Linux, and for some fields Android?

I'm using AmigaOne XE.

Thank you.
PEB
Posts: 567
Joined: Sun Feb 21, 2010 1:28 am

Re: Saving a files on Android

Post by PEB »

You need to specify the Table field that you want (such as: t.InternalStorage).

The following should work on your Amiga:

Code: Select all

t = GetSystemInfo()
DebugPrint(t.Preferences)
DebugPrint(t.TempFiles)
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Saving a files on Android

Post by airsoftsoftwair »

Also note that if you want to write to the path returned in "SDCard" (see above), you need to ask for permission first by using PermissionRequest().
Pierre55
Posts: 54
Joined: Sat Apr 01, 2017 4:25 pm

Re: Saving a files on Android

Post by Pierre55 »

I run your script on a virtual Android (Bluestack)

StringToFile("Hello World", FullPath(GetSystemInfo().InternalStorage, "test.txt"))

But there is no requester asking where I want to save the text file!

Thank you.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Saving a files on Android

Post by airsoftsoftwair »

If you want a requester, you need to use FileRequest() to obtain a path.
Pierre55
Posts: 54
Joined: Sat Apr 01, 2017 4:25 pm

Re: Saving a files on Android

Post by Pierre55 »

Of course... How come I did not think to use FileRequest() ?

Thank you.

Pierre
Pierre55
Posts: 54
Joined: Sat Apr 01, 2017 4:25 pm

Re: Saving a files on Android

Post by Pierre55 »

Well even using FileRequest() on android does nothing... there is no requester!

Anyone can validate that please.

Thank you.

Pierre
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Saving a files on Android

Post by airsoftsoftwair »

Works here. Which Android version are you on?
Post Reply