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:
LogCat connected to: emulator-5554
** Activity (main) Create, isFirst = true **


** Activity (main) Resume **


main_btnsaveas_click (java line: 754)


java.lang.RuntimeException: Path '/mnt/sdcard/Android/data/dictare.om.bun.software/files/DictationFiles'does not exist


at anywheresoftware.b4a.agraham.dialogs.InputDialog$FileDialog.loadFileList(InputDialog.java:1781)
at anywheresoftware.b4a.agraham.dialogs.InputDialog$FileDialog.Show(InputDialog.java:1832)
at dictare.om.bun.software.main._btnsaveas_click(main.java:754)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:63)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Path '/mnt/sdcard/Android/data/dictare.om.bun.software/files/DictationFiles'does not exist
 
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
Top