This is a community forum. You shouldn't limit the question to a single member.hi erel,
Dim r As Reflector
dim pname as string = GetStaticField ("anywheresoftware.b4a.BA", "package name")
File.MakeDir ("/storage/external_sd", pname) 'no Dir created, No Error log
File.MakeDir ("/storage/external_sd/Android/data/", pname)' no Dir created, No Error log
Sub Activity_Create(FirstTime As Boolean)
Dim paths() As Object = GetContext.RunMethod("getExternalFilesDirs", Array(Null))
For Each p As Object In paths
Log(p)
Next
End Sub
Sub GetContext As JavaObject
Return GetBA.GetField("context")
End Sub
Sub GetBA As JavaObject
Dim jo As JavaObject
Dim cls As String = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetFieldJO("processBA")
End Sub
You can use this code on Android 4.4 to find the paths of the app specific external storage paths:
B4X:Sub Activity_Create(FirstTime As Boolean) Log("file.DirInternal " & File.DirInternal ) Log("File.DirDefaultExternal " & File.DirDefaultExternal ) Log("File.DirRootExternal " & File.DirRootExternal ) Log("File.ExternalWritable " & File.ExternalWritable ) Dim paths() As Object = GetContext.RunMethod("getExternalFilesDirs", Array(Null)) For Each p As String In paths Log(p) Next End Sub Sub GetContext As JavaObject Return GetBA.GetField("context") End Sub Sub GetBA As JavaObject Dim jo As JavaObject Dim cls As String = Me cls = cls.SubString("class ".Length) jo.InitializeStatic(cls) Return jo.GetFieldJO("processBA") ***** ERROR LINE 64 End Sub
The first path will be the same as File.DirDefaultExternal.
file.DirInternal /data/data/b4a.example/files
File.DirDefaultExternal /mnt/sdcard/Android/data/b4a.example/files
File.DirRootExternal /mnt/sdcard
File.ExternalWritable true
Error occurred on line: 64 (main)
java.lang.RuntimeException: Method: getExternalFilesDirs not found in: android.app.Application
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:346)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:97)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at b4a.example.main.afterFirstLayout(main.java:98)
at b4a.example.main.access$100(main.java:16)
at b4a.example.main$WaitForLayout.run(main.java:76)
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:3687)
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:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
As I understand it, the restriction is only on writing files. You can still read files created from other apps, so media player can still play your audio file.From what I have gathered, there is a confusion about this news. Just like what Erel has mentioned, only one folder will be allowed in the external SD card and that is for every application. This is just kinda imposing some discipline in the file system usage. If one needs more folder for his/her external files then it has to be created inside that lone folder or the default storage ( the device flash storage). Another info that I have heard is that ownership is implemented in this scheme hence, from KitKat and future Android releases, there will be no sharing of folders among applications. I just thought , could it mean that if your application wrote some audio files in its external folder then other apps like third party media player would not be able to play those files? No wonder it is not a welcome idea to millions of Android fans. But again, this is only for external SD card.
Great!As I understand it, the restriction is only on writing files. You can still read files created from other apps, so media player can still play your audio file.