Bonjour,
J'ai un fichier assets et je souhaiterais pouvoir écrire dans ce fichier à partir d'un InputStream.
Quelqu'un saurait-il m'indiquer comment faire ?
Merci d'avance pour votre aide.
Bonjour,
J'ai un fichier assets et je souhaiterais pouvoir écrire dans ce fichier à partir d'un InputStream.
Quelqu'un saurait-il m'indiquer comment faire ?
Merci d'avance pour votre aide.
Le fichier Assets ne peut être que lu et ouvert.
http://developer.android.com/referen...etManager.htmlThis class presents a lower-level API that allows you to open and read raw files that have been bundled with the application as a simple stream of bytes.
Je pense que l'utilisation d'un Internal ou External Storage serais adapter.
http://developer.android.com/guide/t...a-storage.html
Cordialement ,
Bonjour,
Je ne veux pas dire de bêtise mais il me semble que tu ne peux lire les assets qu'en lecture. la doc :
http://developer.android.com/referen...g.String, int)
et
http://developer.android.com/referen...putStream.html
De même pour les fichier dans le raw.
Tu ne peux écrire que dans des fichier privé ou dans l'external storage
http://developer.android.com/guide/t...a-storage.html
Fichier privé : Using the Internal Storage
external Storage :Using the External Storage
Edit : Arg devancer![]()
est ce que je peux écrire dans un fichier xml dans layout ?
voila le code de création dans un fichier et l'écriture
maintenant je peux accéder à ce fuichier dans android ?
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 String FILENAME = "hello_file"; String string = "hello world!"; FileOutputStream fos = null; try { fos = openFileOutput(FILENAME, Context.MODE_PRIVATE); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { fos.write(string.getBytes()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
Partager