Bonsoir, j'ai un petit souci d'export de données
J'ai autorisé l'accès à l'enregistrement des données dans le manifest, mais le fichier qui ressort de mon application est toujours vide, ce que je ne comprends pas
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 public void enregistrement(Context contexte) throws IOException { lire.lire_CSV(contexte); String contenu= ""; String ligne; int nombre_creatures = lire.getNombre_lignes(); while (compteur < nombre_creatures) { ligne = (lire.getList_creatures().get(compteur).getNumero() + ";" + lire.getList_creatures().get(compteur).getNom() + ";" + lire.getList_creatures().get(compteur).getPv() + ";" + lire.getList_creatures().get(compteur).getMana() + ";" + lire.getList_creatures().get(compteur).getAttaque() + ";" + lire.getList_creatures().get(compteur).getAttaque_max() + ";" + lire.getList_creatures().get(compteur).getDefense() + ";" + lire.getList_creatures().get(compteur).getDefense_max() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_max() + ";" + lire.getList_creatures().get(compteur).getDefense_magique() + ";" + lire.getList_creatures().get(compteur).getDefense_magique_max() + ";" + lire.getList_creatures().get(compteur).getVitesse() + ";" + lire.getList_creatures().get(compteur).getVitesse_max() + ";" + lire.getList_creatures().get(compteur).getTaux_pv() + ";" + lire.getList_creatures().get(compteur).getTaux_pv_max() + ";" + lire.getList_creatures().get(compteur).getTaux_mana() + ";" + lire.getList_creatures().get(compteur).getTaux_attaque() + ";" + lire.getList_creatures().get(compteur).getTaux_defense() + ";" + lire.getList_creatures().get(compteur).getTaux_attaque_magique() + ";" + lire.getList_creatures().get(compteur).getTaux_defense_magique() + ";" + lire.getList_creatures().get(compteur).getTaux_vitesse() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_1_1() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_1_2() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_1_3() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_1_4() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_2_1() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_2_2() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_2_3() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_2_4() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_3_1() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_3_2() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_3_3() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_3_4() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_4_1() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_4_2() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_4_3() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_4_4() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_5_1() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_5_2() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_5_3() + ";" + lire.getList_creatures().get(compteur).getAttaque_magique_5_4() + ";" + lire.getList_creatures().get(compteur).getMagie_1() + ";" + lire.getList_creatures().get(compteur).getMagie_2() + ";" + lire.getList_creatures().get(compteur).getMagie_3() + ",\r\n"); contenu = contenu + ligne; compteur++; } File export = new File(Environment.getExternalStorageDirectory() + "/creatures.csv"); export.createNewFile(); FileOutputStream fout = new FileOutputStream(export); OutputStreamWriter osw = new OutputStreamWriter(fout); osw.append(contenu); fout.close(); }
Partager