samedi 25 avril 2015

Cannot rename a folder


I want to rename a folder :

public static boolean renommerDossierPhoto(String table, String ancienPk, String nouveauPk) {

    if (Integer.parseInt(ancienPk) < 0) { 

        String ancienDir = table + File.separator + "n" + ancienPk.substring(1);

        File ancienDossier = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), DOSSIER_PPAL_PHOTOS + File.separator + ancienDir);

        String nouveauDir = table + File.separator + nouveauPk;

        File nouveauDossier = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), DOSSIER_PPAL_PHOTOS + File.separator + nouveauDir);

        return ancienDossier.renameTo(nouveauDossier);

    }

    return true;

}

The structure of the directories is : internal storage/Pictures/projectName/parcelle/n1/img_20150425_163809.png Here parcelle is the value of the parameter table in the above method. These directories already exist and the folder n1 contains the image img_20150425_163809.png.

So I want to rename the folder n1 to the third parameter , say 5.

At runtime this method returns false ! So what is wrong in my code ?


Aucun commentaire:

Enregistrer un commentaire