Android Question InputStream2 error

SMOOTSARA

Active Member
Licensed User
Longtime User
Hi My friends, where is my mistake? ?

The file is available but I get an error

B4X:
    Log(fPath)
    Log(fName)
    Log("IsDirectory=" & File.IsDirectory(fPath,fName))

    If File.Exists(fPath,fName) Then
   
    Dim InputStream2 As InputStream
    InputStream2 = File.OpenInput(fPath,fName)    '  "File.DirInternal"  name_file
   
end if

line 8 is erorre


B4X:
/data/user/0/app.xxx.aaa.ddd/files/sound
spelling_sound
IsDirectory=true

sqlite_module_v6 (java line: 60)
java.io.FileNotFoundException: /data/user/0/app.xxx.aaa.ddd/files/sound/spelling_sound (Is a directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:231)
    at java.io.FileInputStream.<init>(FileInputStream.java:165)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:214)
    at tablet.vajeh.ge.fa.sqlite_module._v6(sqlite_module.java:60)
    at tablet.vajeh.ge.fa.sqlite_module._chenge_and_rename_and_initialize_master_db(sqlite_module.java:129)
    at tablet.vajeh.ge.fa.main$ResumableSub_Activity_Create.resume(main.java:679)
    at tablet.vajeh.ge.fa.main._activity_create(main.java:364)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at tablet.vajeh.ge.fa.main.afterFirstLayout(main.java:105)
    at tablet.vajeh.ge.fa.main.access$000(main.java:17)
    at tablet.vajeh.ge.fa.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6680)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
 

DonManfred

Expert
Licensed User
Longtime User
file.exists will not work with files from the Files folder. Especially not with sub-folders.

Based on the error spelling_sound is a directory and not a soundfile (it is your filename value)
 
Upvote 0
Top