Makedir on SD card failed
-
xabierpayet
- Posts: 270
- Joined: Fri Feb 24, 2012 9:34 am
Re: Makedir on SD card failed
i cannot query the units, i can write directly to the SDCard but i need to know the correct label of the card used ever, for my tests is enough, but a better solution ever will be nice
Re: Makedir on SD card failed
I think I might have found a solution/workaround
According to this page https://developer.android.com/training/ ... oogle-play the folder /Android/media/ is a part of the shared storage.
I found I could successfully create a folder with any chosen name in the /Android/media/ folder, and this works if using the path /storage/emulated/0/Android/media/ or simply /sdcard/Android/media/
The folder gets created, but I could not manage to create a file inside it, so that seemed quite pointless so far.
But if the directory name is set to the exact same as the name of the compiled Package, then it works and you can create files or copy files into the directory. And the good thing is that the files will be accessable (opposed to the files in the /Android/data/ folders which can not be accessed)
Here is a working example:
According to this page https://developer.android.com/training/ ... oogle-play the folder /Android/media/ is a part of the shared storage.
I found I could successfully create a folder with any chosen name in the /Android/media/ folder, and this works if using the path /storage/emulated/0/Android/media/ or simply /sdcard/Android/media/
The folder gets created, but I could not manage to create a file inside it, so that seemed quite pointless so far.
But if the directory name is set to the exact same as the name of the compiled Package, then it works and you can create files or copy files into the directory. And the good thing is that the files will be accessable (opposed to the files in the /Android/data/ folders which can not be accessed)
Here is a working example:
Code: Select all
@DISPLAY {Title = "Dir test", ScaleMode = #SCALEMODE_AUTO, FitScale = True}
ExitOnError(False)
filedir$ = "/sdcard/Android/media/com.amy66dev.dir1"
TextOut(100, 75, filedir$)
If Exists(filedir$)
TextOut(100, 100, filedir$.." exsists")
Else
TextOut(100, 100, "MAKING DIR 1")
MakeDirectory(filedir$)
EndIf
If Exists(filedir$.."/testfile.dat")
TextOut(100, 125, "File in dir1 exists")
Else
StringToFile("test", filedir$.."/testfile.dat")
TextOut(100, 125, "Creating file in owndir")
EndIf
If Exists("testfile2.dat")
TextOut(100, 150, "File in own dir exists")
Else
StringToFile("test", "testfile2.dat")
TextOut(100, 150, "Creating file in owndir")
CopyFile("testfile2.dat", filedir$)
TextOut(100, 175, "Copying file from owndir")
EndIf
WaitLeftMouseRe: Makedir on SD card failed
After my last post on this matter I found a slightly different method to determinate the shared storage folder.
One could set the filedir$ variable to the shared storage folder location area like this
But I realize I've been overcomplicating things here, since a simple
would do the same thing, since android apear to operate in this area by default anyway.
The actual issue of accessing the external SDCARD remains unresolved
One could set the filedir$ variable to the shared storage folder location area like this
Code: Select all
ta = GetSystemInfo()
filedir$ = ta.InternalStorage.."/testdir"
MakeDirectory(filedir$)Code: Select all
filedir$ = "testdir"
MakeDirectory(filedir$)The actual issue of accessing the external SDCARD remains unresolved
Re: Makedir on SD card failed
I think I have found a better solution now that enables handling files on internal and external storage.
However, I feel that it is more related to APK Compiler than general programming, so I will create a new thread on the matter in the APK Compiler section.
However, I feel that it is more related to APK Compiler than general programming, so I will create a new thread on the matter in the APK Compiler section.