Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Write a xml on SD-Card
    primarykey
    data
    text
    <p>I have a problem with my android-app. I want to save a Data-list in a <strong>xml</strong> and save it to <strong>SD-Card</strong>.</p> <p>Here the code fragment from my activity:</p> <pre><code> Button btnActivity = (Button)findViewById(R.id.modul_save); btnActivity.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Handlerlist templist=new Handlerlist(); //default-constructor for handlerlist Parser_Writer temp_parser=new Parser_Writer(); //default-constructor for praser(writing) templist.add_modul(name, abk, 1, 0, "Hallo", room, 1, 2, 3, 1.3, true); //save input-data in the list temp_parser.write_xml(templist); //calls the parser(writing) Intent in = new Intent(modul_create.this,modul_overview.class); startActivity(in); } }); </code></pre> <p>This is my parser:</p> <pre><code>public class Parser_Writer { public Parser_Writer(){ } public void write_xml(Handlerlist h){ XStream xstream = new XStream(new DomDriver()); try { String xml = xstream.toXML(h); String path=Environment.getExternalStorageDirectory().toString(); File myXml= new File(path+"new.xml"); myXml.createNewFile(); FileWriter fileIO =new FileWriter(myXml); fileIO.write("&lt;?xml version='1.0' encoding='utf-8'?&gt;"); fileIO.write(xml.toString()); fileIO.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } </code></pre> <p>}</p> <p>I also add the <code>android.permission.WRITE_EXTERNAL_STORAGE</code>... but i can not write on my storage!! I got the following logcat-message:</p> <pre><code>java.io.IOException: Read-only file system at java.io.File.createNewFileImpl(Native Method) at java.io.File.createNewFile(File.java:1160) at Parser.Parser_Writer.write_xml(Parser_Writer.java:38) at StundentenApp.main.modul_create$1.onClick(modul_create.java:51) at android.view.View.performClick(View.java:2408) at android.view.View$PerformClick.run(View.java:8816) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4627) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>Someone here who could help me?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload