Page 1 of 2

android external SD save/delete problem

Posted: Sun Aug 14, 2016 1:03 am
by xabierpayet
i found a bug (or not) in the android version of hollywood, if i attempt to save any file to the external SD in my phone
i have this error message:

Hollywood player
cannot write to file/storage/extsdcard/multijocs/a.cfg
file:p_loadsave.hws (current line: 127 in function openfile)

* deleting files i have the same problem
* loading files from the SD is working fine


if i try the same example in a sony xperia z phone or in a samsung galaxy tab 2, the example work fine, but in the galaxy grand prime or in the xperia t this is not working, do you know how to solve this? i need to write in the external SD

Re: android external SD save/delete problem

Posted: Sun Aug 14, 2016 9:02 pm
by airsoftsoftwair
Small code snippet please :)

Re: android external SD save/delete problem

Posted: Mon Aug 15, 2016 1:59 am
by xabierpayet
the snippet, under all the plattforms is working fine, in android too, but i don´t know why in some android versions don´t let write to the SD card, but i can create files, delete or rename with all the android apps in the market on them

path$ = PathRequest("Select a path")
save$="123.txt"
savestr$="456"
save$=path$.."/"..save$
openfile(1,save$,#mode_write)
writeline(1,savestr$)
closefile(1)

Re: android external SD save/delete problem

Posted: Mon Aug 15, 2016 11:32 am
by airsoftsoftwair
What happens if you try to write to GetSystemInfo().ExternalStorage? e.g.

Code: Select all

a$ = FullPath(GetSystemInfo().ExternalStorage, "test.txt")
OpenFile(1,a$,#MODE_WRITE)
WriteLine(1,"Test")
CloseFile(1)
Does it work?

Re: android external SD save/delete problem

Posted: Mon Aug 15, 2016 11:33 pm
by xabierpayet
doesn´t work, i dont have error message, but the file was not created

Re: android external SD save/delete problem

Posted: Tue Aug 16, 2016 12:21 am
by xabierpayet
i try it with:

a$ = FullPath(GetSystemInfo().SDCard, "test.txt")

too with not luck

Re: android external SD save/delete problem

Posted: Tue Aug 16, 2016 1:04 am
by xabierpayet
here you have 2 screenshots of my storage and emulated folders:
Image
Image
and other of :
a$ = FullPath(GetSystemInfo().... different combinations
Image

Re: android external SD save/delete problem

Posted: Tue Aug 16, 2016 6:37 pm
by airsoftsoftwair
It works here on all my devices. What Android version is running on the devices where it doesn't work?

Do you get an error message when running this code or is the file just not created? I didn't really understand this from your previous comments.

Code: Select all

a$ = FullPath(GetSystemInfo().ExternalStorage, "test.txt")
OpenFile(1,a$,#MODE_WRITE)
WriteLine(1,"Test")
CloseFile(1)

Re: android external SD save/delete problem

Posted: Tue Aug 16, 2016 9:11 pm
by xabierpayet
Using normal save instruction:
work in 4.4.4 samsung galaxy tab 2
No work in samsung galaxy grand prime 5.1.1
here...

using:

a$ = FullPath(GetSystemInfo().SDCard, "test.txt")
b$=GetSystemInfo().SDCard
OpenFile(1,a$,#MODE_WRITE)
WriteLine(1,"Test")
CloseFile(1)
debugprint(b$)
files = FileRequest("Search file", "*",#REQ_MULTISELECT,b$)

i see some things, the file is saved but in the internal memory, and the debug output say:
/storage/emulated/0

if i change sdcard for externalstorage, the file is saved in other place, but not in the sd card, this happen in the 2 devices

a$ = FullPath(GetSystemInfo().ExternalStorage, "test.txt")
b$=GetSystemInfo().SDCard
OpenFile(1,a$,#MODE_WRITE)
WriteLine(1,"Test")
CloseFile(1)
debugprint(b$)
files = FileRequest("Search file", "*",#REQ_MULTISELECT,b$)

and the debug output say:
/storage/emulated/0/Android/data/com.lotofxxxxx.xxx/files

both situations work in the devices in the same way, exactly, i don´t have error why the file really is saved, but not in the root of the SD card, or in an custom drawer

Re: android external SD save/delete problem

Posted: Wed Aug 17, 2016 11:52 am
by airsoftsoftwair
Ok, now I see what you mean. There's nothing wrong with Hollywood here. Hollywood just uses the paths that Android reports. However, external storage and SDCard don't necessarily mean external storage and SDCard :) As usual with Android, it's all up to the decision of the device manufacturer what these paths actually point to. That's why it works on one device and doesn't work on the other. See here for a more detailed explanation:
http://stackoverflow.com/questions/5694 ... d-location