I need to create an XML file whose name is the title and the date when it was created, to differentiate it from the other XML. The problem is that when I try to create the file an exception is thrown if the name of this one involves a variable:
File ruta_sd = Environment.getExternalStorageDirectory();
File f = new File(ruta_sd.getAbsolutePath(),"prueba.xml");
dos = new DataOutputStream(new FileOutputStream(f));
This creates it without problems, on the other hand if it were like this
File ruta_sd = Environment.getExternalStorageDirectory();
File f = new File(ruta_sd.getAbsolutePath(),momento+"prueba.xml");
dos = new DataOutputStream(new FileOutputStream(f));
Being a String where I save the date, it says that the file is not found and throws an exception, can any one illuminate me?
Variable moment:
calendario= Calendar.getInstance();
hora=calendario.get(Calendar.HOUR_OF_DAY);
minutos=calendario.get(Calendar.MINUTE);
segundos=calendario.get(Calendar.SECOND);
año=calendario.get(Calendar.YEAR);
mes=calendario.get(Calendar.MONTH)+1;
dia=calendario.get(Calendar.DAY_OF_MONTH);
momento=dia+"/"+mes+"/"+año+" - "+hora+":"+minutos+":"+segundos;
This last in onCreate ()