As I said, I am not able to access the path of the sd card, it returns the path / emulated / 0 that is the internal memory. a greeting and I hope your help! I attach the code
public void grabar(){
String nomarchivo = et1.getText().toString();
String contenido = et2.getText().toString();
try {
File tarjeta = Environment.getDataDirectory();
Toast.makeText(this, getExternalFilesDir(Environment.getDataDirectory().getAbsolutePath()).getAbsolutePath(), Toast.LENGTH_LONG).show();
File file = new File(s,nomarchivo);
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(file));
osw.write(contenido);
osw.flush();
osw.close();
Toast.makeText(this, "Los datos fueron grabados correctamente", Toast.LENGTH_SHORT).show();
et1.setText("");
et2.setText(s);}
catch (IOException ioe) {
Toast.makeText(this, "No se pudo grabar", Toast.LENGTH_SHORT).show();
}
}