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
|
public class fichier {
public static void ecrireFichier(String nomFichier,ArrayList<String> a,Context c) {
BufferedWriter writer = null;
try {
//Context c=
//File dir=getPackageManager().getLaunchIntentForPackage("com.example.appli1");
File dir = c.getExternalFilesDir("ToutMesFichiers");
dir.mkdirs();
File newfile = new File(dir,nomFichier);
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newfile)));
for(int i=0;i<a.size();i++){
writer.write(a.get(i)+"\n");
}
} catch (Exception e) {
Log.e("NoteActivity","Failed to write file",e);
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
Log.e("NoteActivity","erreur",e);
}
}
}
}
} |
Partager