Android Question How to Get Android 9+ to allow user to choose an app To run a path&filename string?

Joanna

Member
'everything is lowercase, no spaces. the file is there. I can load it manually
'B4A v11
'
'example:
'FN="/storage/emulated/0/download/barbie.txt"
'Dim I As Intent
'i.Initialize(i.ACTION_VIEW, FN)
'FN="content://" & FN
'i.SetType("text/plain")
'StartActivity(i)
'


Great!
Popup appears, Open.. or.. Use a different app...

I try many apps. Ex: X-plore
they all give me same error
Get error: unable to open file barbie.txt
No content provider: content:///storage/emulated/0/download/barbie.txt

Honestly, I dont care about mime types. Let the user decide.

I also tried changing all that to a jpg file and image/* and get same error msgs.

I thought this was going to be easy, but I was wrong.

any simple suggestions?
-JoAnna
 

Joanna

Member
Hmm. So I need to save barbie.txt to my MicroSD card /01234-56789/download/barbie.txt
and then do StartActivity(i) to that path?
I thought " Starting from Android 4.4 it is no longer possible to directly access external storages "
which made Sd card almost useless? (In cases like this)
From what I know, ContentChooser will not bring up the file you want the user to open. User has to go searching for file/path?
-JoAnna
 
Upvote 0

Joanna

Member
is there anywhere on the entire Android device that I can put 'barbie.txt' so it can be 'directly' accessed by any app?
without using content chooser or file provider
-JoAnna
 
Upvote 0

Joanna

Member
Erel, I read your reply wrong. I got all confused. Forgive me.

Let me correct myself. My problem is the Startactivity(i).

'below works in Android 7, 9, 11 in any of my programs. This is good for me.
'EditText2.Text=File.ReadString("/storage/emulated/0/download/","barbie.txt")

it is the StartActivity that I can't get to work.

I can't have our 70 year old mom trying to use content chooser/etc to find folders/files/etc.
that's just too much for her. I want to do all the work for her.

Click a button and Android loads up her default TEXT viewer or .pdf viewer.. whatever.

she has Android v11

-JoAnna
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Upvote 0

Joanna

Member
'example:
'FN="/storage/emulated/0/download/barbie.txt"
'Dim I As Intent
'i.Initialize(i.ACTION_VIEW, FN)
'FN="content://" & FN
'i.SetType("text/plain")
'StartActivity(i)

Thank you for your help guys.
I had to give up on this. Just cant get it to work.
Maybe I need to convert a simple string(FN) to a URI in order for the above example to work?
I went with adding another panel, with basically my own text viewer.

My brother(Scottie) is also having trouble accessing Android's file system.
But he is trying to read/write to android/data folders. Don't think he's gonna do it.
Google has ruined it.

Anyways, This girl has a hair salon appointment to get to.

Thanks again,
JoAnna
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…