Bonjour,

Je n'arrive pas a supprimer une photo de la mémoire interne !

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
 
 
    public static void delFile(String pathToFile) throws IOException {
        File file = new File(pathToFile);
        if(file.exists()){
        	System.out.println("Fichier trouvé");
        }else{
        	System.out.println("Fichier non trouvé");
        }
        if (file.delete() == false) {
            throw new IOException();
        }
    }
 
		try {
			delFile(Environment.getExternalStorageDirectory()+
	    	        "/DCIM/Camera/1337762945140.jpg");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
Il me déclenche l'exception, le fichier est bien trouvé

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
 
 
05-23 11:26:45.429: I/System.out(6231): Fichier trouvé
05-23 11:26:45.429: W/System.err(6231): java.io.IOException
05-23 11:26:45.429: W/System.err(6231): 	at com.test.android.AuthentificationActivity.delFile(AuthentificationActivity.java:166)
05-23 11:26:45.429: W/System.err(6231): 	at com.test.android.AuthentificationActivity.onCreate(AuthentificationActivity.java:50)
05-23 11:26:45.429: W/System.err(6231): 	at android.app.Activity.performCreate(Activity.java:4411)
05-23 11:26:45.429: W/System.err(6231): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
05-23 11:26:45.429: W/System.err(6231): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1781)
05-23 11:26:45.429: W/System.err(6231): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1833)
05-23 11:26:45.429: W/System.err(6231): 	at android.app.ActivityThread.access$500(ActivityThread.java:124)
05-23 11:26:45.429: W/System.err(6231): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1026)
05-23 11:26:45.429: W/System.err(6231): 	at android.os.Handler.dispatchMessage(Handler.java:99)
05-23 11:26:45.429: W/System.err(6231): 	at android.os.Looper.loop(Looper.java:132)
05-23 11:26:45.429: W/System.err(6231): 	at android.app.ActivityThread.main(ActivityThread.java:4134)
05-23 11:26:45.429: W/System.err(6231): 	at java.lang.reflect.Method.invokeNative(Native Method)
05-23 11:26:45.429: W/System.err(6231): 	at java.lang.reflect.Method.invoke(Method.java:491)
05-23 11:26:45.429: W/System.err(6231): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-23 11:26:45.429: W/System.err(6231): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-23 11:26:45.429: W/System.err(6231): 	at dalvik.system.NativeStart.main(Native Method)
Pourtant j’ai bien mit les droits d'accès dans le manifest :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
<uses-permission android:name="android.permision.WRITE_EXTERNAL_STORAGE"></uses-permission>
Je ne sais pas pourquoi je n'arrive pas a faire une choses aussi simple !