[android] getFilesDir() vs Environment.getDataDirectory()

I want to replace one context method with Environment variable.
But not sure if they mean the same.

What is the difference between

getFilesDir() and Environment.getDataDirectory() ?

How can I get data\data as a from of data\data\com.Myapp using Environment Variable?

This question is related to android

The answer is


getFilesDir()

Returns the absolute path to the directory on the filesystem where files created with openFileOutput(String, int) are stored.

Environment.getDataDirectory()

Return the user data directory.


Environment returns user data directory. And getFilesDir returns application data directory.


Try this

getExternalFilesDir(Environment.getDataDirectory().getAbsolutePath()).getAbsolutePath()