bonjour voilà ce que j'ai fait
je trouve le fichier mais FileToDelete.delete et FileToDelete.canWrite retourne false je ne peut pas supprimer le fichier
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 procedure TForm3.DeleteFileFromDownloadFolder(const FileName: string); //AndroidManifest.xml (*<?xml version="1.0" encoding="UTF-8"?> <!-- BEGIN_INCLUDE(manifest) --> -<manifest android:installLocation="auto" android:versionName="1.0.0" android:versionCode="1" package="com.embarcadero.Project1" xmlns:android="http://schemas.android.com/apk/res/android"> <!-- END_INCLUDE(manifest) --> <uses-sdk android:targetSdkVersion="30" android:minSdkVersion="23"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.CALL_PHONE"/> <uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-feature android:required="true" android:glEsVersion="0x00020000"/> <queries> </queries> -<application android:requestLegacyExternalStorage="true" android:resizeableActivity="false" android:hardwareAccelerated="true" android:theme="@style/AppTheme" android:icon="@drawable/ic_launcher" android:largeHeap="False" android:debuggable="true" android:label="Project1" android:restoreAnyVersion="False" android:persistent="False"> <!-- Our activity is a subclass of the built-in NativeActivity framework class.This will take care of integrating with our NDK code. --> -<activity android:name="com.embarcadero.firemonkey.FMXNativeActivity" android:label="Project1" android:launchMode="singleTask" android:configChanges="orientation|keyboard|keyboardHidden|screenSize"> <!-- Tell NativeActivity the name of our .so --> <meta-data android:name="android.app.lib_name" android:value="Project1"/> -<intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <receiver android:name="com.embarcadero.rtl.notifications.NotificationAlarm"/> </application> </manifest> *) var DownloadPath: JFile; FileToDelete: JFile; begin DownloadPath := TJFile.JavaClass.init(TJEnvironment.JavaClass.getExternalStoragePublicDirectory(TJEnvironment.JavaClass.DIRECTORY_DOWNLOADS), StringToJString('')); FileToDelete := TJFile.JavaClass.init(DownloadPath, StringToJString(FileName)); if FileToDelete.Exists then begin // FileToDelete.setWritable(true) ;// FileToDelete. if FileToDelete.canWrite then Memo1.Lines.Add('Le fichier ' +FileName+' Ok en écriture') else Memo1.Lines.Add('Le fichier ' +FileName+' n''est pas Ok en écriture'); if FileToDelete.delete then Memo1.Lines.Add('Le fichier ' +FileName+' a été supprimé dans le dossier '+ JStringToString(DownloadPath.toString)) else Memo1.Lines.Add('Le fichier ' +FileName+' n''a pas été supprimé dans le dossier ' + JStringToString(DownloadPath.toString)); end else Memo1.Lines.Add('Le fichier ' +FileName+' n''a pas été trouvé dans le dossier ' + JStringToString(DownloadPath.toString)); end; procedure TForm3.btnShowSelectedClick(Sender: TObject); begin DeleteFileFromDownloadFolder('A.txt'); end;
si quelqu'un a une idée merci
Partager