Android Question Attempt to make a local folder

David Acre

New Member
Licensed User
Longtime User
This sounds easier than it is. I make the app and install it. The app checks for a local folder (called search) at "/storage/emulated/0". If the "search" folder does not exist, then it tries to create it. The File.ExternalWritable indicates the local drive is writable. It performs a
File.MakeDir( "/storage/emulated/0", "search") and the try-catch does not fail. When I check the local folders, the "search" folder is not there, but doesn't it have to be since it didn't throw an error?
Goal: Once this folder is made, I want to be able to write my own text file called search.txt to it, so the installed app can then read it, and I'll be able to update the search.txt file any time I want just by copying over USB or whatever. Note that this must work with no root privilege.
 

JohnC

Expert
Licensed User
Longtime User
Does any other app need to be able to access that file?

If not, then simply use the directory "File.DirInternal" - which is only accessible from your app and doesn't need any special write permissions.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
/storage/emulated/0
is equivalent to File.DirRootExternal and to write here you need to use RuntimePermission and request the permission first.

In case of any other app need to be able to access that file ;-)
See @JohnC answer.
 
Upvote 0

David Acre

New Member
Licensed User
Longtime User
Currently my app cannot even create the folder at the path DirRootExternal . Once it does create a folder, doesn't that app have access to it without any special permissions? Is this a manifest issue? I know Android wasn't so peculiar a few years back. Once the app has created the folder, then I can put my text file out there to permit it to be read by my app as needed. Then later I can use a text editor to open the same text file and update it as required. This really shouldn't be this difficult, I know.
 
Upvote 0

David Acre

New Member
Licensed User
Longtime User
I get "Maven artifact not found: com.android.support/support-v4" now when compiling since I have added the library ref and this code:
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result=False Then
Msgbox("false.." ,"")
End If
Is there something else that needs to be downloaded and installed?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Here's a thread that might help:

 
Upvote 0

David Acre

New Member
Licensed User
Longtime User
I am attempting to run using RuntimePermissions, but no luck.

I get "Maven artifact not found: com.android.support/support-v4" now when compiling since I added the library ref and this code:
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result=False Then
Msgbox("false.." ,"")
End If

I am referencing this web page below for explicit instructions for installation of B4A v9.50 .

https://www.b4x.com/b4a.html#installation

1) Is this the most current set of install instructions?

2) Should I uninstall B4A and then follow the steps as listed to correct the error?
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
1) Is this the most current set of install instructions?
Yes

2) Should I uninstall B4A and then follow the steps as listed to correct the error?
Probably not. Try using forum search and try some of the solutions listed, i.e.:

 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
I advise you to first follow JohnC and DonManfred advice to start by first writing only to file in the app environment without run time permission. For Android, the security rule has been greatly increased recently. That is why it has become very difficult to access data outside the app environment. Even some working run permission examples in the past now lead to all kinds of error messages.
.
Can you post your code on the forum and please use the </> button for the code tags for better readability
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
1. @David Acre

Please use [CODE]code here...[/CODE] tags when posting code.

codetag001.png

codetag002.png

codetag003.png


I advise you to first follow JohnC and DonManfred advice to start by first writing only to file in the app environment without run time permission
Neither JohnC or me does suggest THIS.

We advices NOT to use this storage without having requested Permission first.

@David Acre Please upload a small project which shows the issue.

I get "Maven artifact not found: com.android.support/support-v4" now when compiling

Can you please post:
1. The full path to your android.jar (Tools -> Configure Paths)
2. The Full Path to sdkmanager.bat configured in the B4A SDKManager (open the SDK Manager to see the path)
 
Last edited:
Upvote 0
Top