Android - open failed: EACCES (Permission denied)

 
Vista:
sin imagen de perfil

open failed: EACCES (Permission denied)

Publicado por Miquel Angel (6 intervenciones) el 27/10/2015 12:26:17
Hola

me sale siempre el mismo error
10-27 12:14:57.380 13903-13903/herprogramacion.tarjetasd I/System.out: /storage/140E-0B09/mifichero.txt: open failed: EACCES (Permission denied)

he visto respuestas en internet pero no me acabo de aclarar por que soy nuevo en android y no me acaban de quedar clara las respuestas, alguien me lo podría explicar en nivel bajo para que opciones puedo probar para solucionarlo.
Intento escribir en un fichero SD.

Mi codigo es

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
public class MainActivity extends AppCompatActivity {
 
    private EditText et1, et2;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        et1=(EditText)findViewById(R.id.editText);
        et2=(EditText)findViewById(R.id.editText2);
    }
 
 
    public void grabar(View view)
    {
        String nomarchivo = et1.getText().toString();
        String contenido = et2.getText().toString();
 
        try{
            File tarjeta = Environment.getExternalStorageDirectory();
            Toast.makeText(this,tarjeta.getAbsolutePath(),Toast.LENGTH_LONG).show();
            File file = new File(tarjeta.getAbsoluteFile(), nomarchivo);
            OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(file));
            osw.write(contenido);
            osw.flush();
            osw.close();
            Toast.makeText(this,"Datos grabados correctamente",Toast.LENGTH_SHORT).show();
            et1.setText("");
            et2.setText("");
        } catch (IOException e)
        {
            System.out.println(e.getMessage().toString());
            Toast.makeText(this,"No se pudo grabar",Toast.LENGTH_SHORT).show();
        }
    }
 
    public void recuperar(View v) {
        String nomarchivo = et1.getText().toString();
        File tarjeta = Environment.getExternalStorageDirectory();
        File file = new File(tarjeta.getAbsolutePath(), nomarchivo);
        try {
            FileInputStream fIn = new FileInputStream(file);
            InputStreamReader archivo = new InputStreamReader(fIn);
            BufferedReader br = new BufferedReader(archivo);
            String linea = br.readLine();
            String todo = "";
            while (linea != null) {
                todo = todo + linea + " ";
                linea = br.readLine();
            }
            br.close();
            archivo.close();
            et2.setText(todo);
 
        } catch (IOException e) {
            Toast.makeText(this, "No se pudo leer",
                    Toast.LENGTH_SHORT).show();
        } //catch
    }
 
}

y en android manifest he puesto

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="herprogramacion.tarjetasd" >
 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <activity android:name=".MainActivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
 
</manifest>


alguna idea de que falla?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

open failed: EACCES (Permission denied)

Publicado por Joge Luis Colunga (1 intervención) el 01/03/2017 20:59:11
Ami me pasa lo mismo con el mismo codigo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar