Android Question File.DirInternal problem

Douwe Siegersma

Member
Licensed User
Hi,

I want to save some data in File.DirInternal using the FilePicker library from DonManfred.
When initializing the filepicker I set File.DirInternal as root directory. When I run the app in debug mode I get the message:
"Application needs your permission to access SD card". The compiled app just crashes.
Regards,

Douwe
 

JohnC

Expert
Licensed User
I know it sounds like it should "not" need permission because the directory is "internal" to the app.

But see if it does fix the issue if you try adding in the read and write permissions for the external storage as shown in the READ_EXTERNAL_STORAGE / WRITE_EXTERNAL_STORAGE section of this page:

 
Upvote 0

Mahares

Expert
Licensed User
I know it sounds like it should "not" need permission because the directory is "internal" to the app.
When initializing the filepicker I set File.DirInternal as root directory.
@JohnC : You are correct, you do not need permission to access File.DirInternal. Data in the internal folder is private to the app. It can only be accessed within its app. I do not think you can use file provider to even access it. This is how I knew it, unless things changed and I am not aware of it.
 
Upvote 0

JohnC

Expert
Licensed User
I do not think you can use file provider to even access it.
That's why I'm curious if the permissions will allow it to work.
 
Upvote 0

Douwe Siegersma

Member
Licensed User
Hello,

Thank you all for your support. Now I know that File.DirInternal is for the App only. Not for storing userfiles.
I use this directory because any other directory fails with FilePicker. I wanted to use File.DefaultDirExternal but then I get the message that the directory cannot be found and the default directory will be used instead. And in fact it doesn't. The directory "/storage/emulated/0/Android/data/b4a.example/files" just is not there. I tried to make the directory myself but that doesn't work.
Regards,

Douwe
 
Upvote 0

LucaMs

Expert
Licensed User
Upvote 0

Douwe Siegersma

Member
Licensed User
I do not have the sourcecode of the FilePicker so I'm unable to see where things go wrong. Maybe there is a less advanced file-dialog I can use?
 
Upvote 0

DonManfred

Expert
Licensed User
If you are using this Library i guess it uses the External Storage (File.DirRootExternal) or similar path.

So it would be mandatory to use Runtimepermissions and request Permission for.

The Library and Example are 4 Years old.
 
Upvote 0

Douwe Siegersma

Member
Licensed User
Still one question: how to retrieve the full filenaam chosen in FilePicker.
I tried:

B4X:
Sub FilePicker_onSelectedFilePaths(selected() As String)
    FileNaam = ""
    For i = 0 To selected.Length -1
        FileNaam = FileNaam & selected(i)
    Next
    fp.dismiss
End Sub

But the App crashes when I use Filenaam to open the chosen file. The error states it is a directory.
 
Upvote 0

DonManfred

Expert
Licensed User
I suggest to understand what the Event deliver to you and what you do with the given info.
The event is named onSelectedFilePaths so it suggests a multiple List of a FilePath.
It makes no sence to combine the answers. Probably only one is inside the List.

Away from that at the end you have FileNaam with a PATH filled.

Maybe you just selected a Folder instead of a File?

To help you you should have posted what the Result is in that event. Add log output to the event.

For any other question: Please start a new thread for any new Question/Issue you have. One thread should summarize one Question.
 
Upvote 0
Top