I have written the code below, but I keep receiving errors about Path Separator.
btn_guardar.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            final String CP7_String = et_id.getText().toString();
            final String ncontagem_String = et_ncontagem.getText().toString();
        Thread thread = new Thread () {
                public void run() {
                      String PATH=null ;
                            FileOutputStream fileos = null;
                            try{
                                    if(fileos==null)
                                {
                                    // If the file don't exists
                                    File file = new File(Environment.getExternalStorageDirectory().toString()+"/xml_nova_contagem.xml" );
                                    fileos = new FileOutputStream(file);
                                }
                                        // If the file exists
                        /////////-------- THIS METHOD WON'T WORK --------///////
                                    /*  if (fileos!=null){
                                           System.out.println("aqui vai dar bronca: " + Environment.getExternalStorageDirectory().toString());
                                    //     PATH = Environment.getExternalStorageDirectory().toString() + "/xml_nova_contagem.xml";
                                           Context context= getApplicationContext();
                                           fileos = context.openFileOutput("xml_nova_contagem.xml", Context.MODE_APPEND);
                                           System.out.println("okkkkkkkkk ");
                                            }
                                             */
                            XmlSerializer serializer = Xml.newSerializer();
                            try{
                                serializer.setOutput(fileos, "iso-8859-1");
                                serializer.startDocument(null, Boolean.valueOf(true));
                                serializer.startTag(null, "CodigoPostal");
                                serializer.startTag(null, "CP7");
                                serializer.text(CP7_String);
                                serializer.endTag(null,"CP7");
                                serializer.startTag(null,"NovaContagem");
                                serializer.text(ncontagem_String);
                                serializer.endTag(null, "NovaContagem");
                                serializer.endTag(null, "CodigoPostal");
                                serializer.endDocument();
                                serializer.flush();
                                fileos.close();
                                System.out.println("endddddddddda");
                                }catch(Exception ee)
                                {
                                    System.out.println("Exception"+ee);
                                }
                        }
                    catch (Exception e) {
                        System.out.println("Erro a escrever"+e);
                        System.out.println("path"+PATH);
                    } 
               }
                    };thread.start();
        }
    });
}
}
I require opening a file on my SDCard, however, I am unable to do so. It is intended to add new records to an existing XML file, but since I am unable to read it, I am unable to do so. This approach won't work, but I have another one that creates the XML file and adds the record, and it does.