DirDefaulExternal error

laviniut

Active Member
Licensed User
Longtime User
I use some code to save the files. All is ok on my Galaxy S2 phone, also on AVD with android 4.1.2
But when i test it on AVD with android 2.3.3 and 3.1, give me an error.
The code i use:
B4X:
Dim PadDir As String                            : PadDir = File.DirDefaultExternal & "/DictationFiles"
Dim PadFileName As String
...
If FirstTime AND File.Exists(PadDir, "*.*") = False Then
        File.MakeDir(File.DirDefaultExternal, "DictationFiles")
       
    End If
...
File.WriteString(PadDir, PadFileName, EditPad.text)
So, is File.DirDefaultExternal functional only after android 4 ?
And how can i save the files in android 2 and 3 ?
 

laviniut

Active Member
Licensed User
Longtime User
I set PadFileName after a dialog, like this:
B4X:
PadFileName=fd.ChosenName & ".txt"
But everything is ok and all application works fine in my Galaxy S2 phone with android 4.1.2
and now i need to test application in other devices.
the error i get in android 2.3.3 and 3.1 in AVD is:
 
Upvote 0

laviniut

Active Member
Licensed User
Longtime User
I search in AVD 2.3.3 and there is no such a path: /mnt/sdcard/Android/data
only /mnt/sdcard
so there is the problem. with path created by
File.DirDefaultExternal
But how can i solve the problem with different android version ?
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
File.DirDefaultExternal works with all versions.

On the emulator you should make sure that it is configured with a sd card.

Can you post the full code? I don't see how is FileDialog related to the code in the first post.

You should also replace this line:
B4X:
Dim PadDir AsString : PadDir = File.DirDefaultExternal & "/DictationFiles"

With:

B4X:
Dim PadDir As PadDir = File.Combine(File.DirDefaultExternal, "DictationFiles")
 
Upvote 0

laviniut

Active Member
Licensed User
Longtime User
My mistake. Because i was in a hurry to test my first final application on different devices, i omitted to set sdcard in AVD.
Now I created a new AVD and is working. Thank you.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…