Maurício Giordano
Maurício Giordano

Reputation: 3276

EACCES (Permission denied). Trying to access a file created by another application Android

I'm trying to read a file created by another Android application.

    File file = new File("/data/data/air.br.com.screencorp.MobilePlayer/br.com.screencorp.MobilePlayer/Local Store/token");
    FileInputStream fis = null;

    try {
        fis = new FileInputStream(file);

        Log.d("SIZE", "Total file size to read (in bytes) : "
                + fis.available());

        int content;
        StringBuilder token = new StringBuilder();

        while ((content = fis.read()) != -1) {
            token.append((char) content);
        }

        Log.d("TOKEN", token.toString());

    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            if (fis != null)
                fis.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

I don't know why, but I'm not allowed to access that file. I have the READ_EXTERNAL_STORAGE permission on my manifest.

Should I use SharedPreferences?

Thanks.

Upvotes: 0

Views: 216

Answers (1)

nandeesh
nandeesh

Reputation: 24820

Data of other applications private data can not be accessed from your app. This is the security model of android. The app should have set MODE_WORLD_READABLE permission on the file, only then can you access the file

Upvotes: 1

Related Questions