Android Question Permission denied

FerGeoRi

Active Member
Licensed User
Bonjour
Le fait de passer android:targetSdkVersion de 19 à 28 rend mon application inopérante.
Je lis et j'ecris des fichiers.

Pouvez-vous me donner la solution ?
Un grand meci pour vos réponses.
Cordialement.
FerGeoRi
 

JohnC

Expert
Licensed User
Longtime User
Try adding runtime permission for read and write external memory:

 
Upvote 0

FerGeoRi

Active Member
Licensed User
Bonjour
Merci pour la réponse.
Mais mon gros problème c'est l' Anglais.
Et donc, consulter le didactitiel de Erel, ne m'aide pas du tout.
En plus, on m'a indiqué un forum Francais et à chaque retour de question, tout est anglais.
Si je laisse mon application en android:targetSdkVersion=19, cela fonctionne.
C'est quoi le risque ?
FerGeoRi
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Il n'y a probablement aucun risque si vous ne souhaitez pas mettre votre application sur Google PlayStore.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Do you need to write files to File.DirRoot External?

With Google-Translator:
Avez-vous besoin d'écrire des fichiers dans File.DirRootExternal?
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Pour gérer File.DirRootExternal:
- Ajoutez ceci au Manifest
B4X:
AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="19" />
)
- Dans Process Globals ajouter:
B4X:
Private rp as RuntimePermissions
- Dans votre code avant de gérer les fichiers, mettez:
B4X:
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then
    'Gérer les fichiers
Else
    'Informez l'utilisateur que l'autorisation est nécessaire
    'pour continuer et abandonner l'action sur les fichiers
End If
Espérons que cela peut vous aider.
Le français n'est pas ma langue.
J'ai tout fait avec Google Translator.
Je m'attendais à être simple d'avoir des réponses dans le forum français de toute façon. ? ? ?
 
Last edited:
Upvote 0

FerGeoRi

Active Member
Licensed User
Good evening
Thank you for your response Sagenut.
I want to put my application on PlayStore.
Once compiled it will of course be installed in /storage/emulated/0/Android/Data/.
This application manages 14 files that store the data entered.
These 14 files can be found in /storage/emulated/0/Android/Data/b4a.example/MesTel/
It worked very well in android:targetSdkVersion="19".
Sincerely
FerGeoRi
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
/storage/emulated/0/Android/Data/b4a.example/MesTel/
The above folder you are showing, if your target SDK is 28 is referred to as:
B4X:
rp.GetSafeDirDefaultExternal("MesTel")
All you need is to declare runtimepermission using Dim rp as runtimepermissions. or Private rp as runtimepermissions You do not need to request permission for it. Since everyone is practicing their French: Allez, Bonne Chance.
 
Upvote 0

FerGeoRi

Active Member
Licensed User
Hello.
Thank you Mahares for your answer.
rp.GetSafeDirDefaultExternal("MesTel") gives me :
/storage/emulated/O/Android/data/com.MyCalepinVL/files/MesTel, while I want to put my files in /storage/emulated/O/Android/data/b4a.example/MesTel.

But Sagenut made me smile again.
I applied his three changes in Manifest, Process Global, in the code before managing the files and my application is back up and running.
Currently the publication is systematically refused at the Authorizations level.
I will come back to call for help if I can't find the solution.
Cordially.
FerGeoRi
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
/storage/emulated/O/Android/data/com.MyCalepinVL/files/MesTel, while I want to put my files in /storage/emulated/O/Android/data/b4a.example/MesTel.
I do not think you can do that. When you use rp.GetSafeDirDefaultExternal("MesTel") , you see: com.MyCalepinVL which is the package name of the application. You definitely want to use rp.GetSafeDirDefaultExternal("MesTel"). But if you want to save it into File.DirRootExternal or one of its subfolders, you need the runtimepermissions code and you need to create the subfolder in the root. For example: to have the data stored in this subfolder, you need something like this:
File.DirRootExternal & "/FerGeoRi" if the subfolder name is: FerGeoRi
Salutations
 
Upvote 0
Top