how to access the external card path in android 6.0 forward?

0

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();
        }
}
    
asked by MR. PUNK 27.02.2017 в 20:47
source

1 answer

1

To access the external storage route you must use getExternalFilesDir

To access the internal storage route, you must user getFilesDir ()

You're using getExternalFilesDir and report back the path /emulated/0 , you are definitely in the external storage, the external storage path is similar to data/data .

    
answered by 27.02.2017 в 21:05