skip to Main Content
File filePath = new File(Environment.getDataDirectory().getAbsolutePath());

But i return only /data, so where is /data is located and how i get andrid/data/"package_name"/

2

Answers


  1. Though this is not the write way of getting the package name from your data folder but this can be used as a temporary solution:

    File file=getApplicationContext().getFilesDir();
    

    Thanks to @blackapps for making the solution more simple.

    Login or Signup to reply.
    • I will describe here which method returns which path.
    Methods Output Path
    Environment.getDownloadCacheDirectory() /data/cache
    Environment.getExternalStorageDirectory() /storage/emulated/0
    CONTEXT.getExternalCacheDirs()[0] /storage/emulated/0/Android/data/YOUR_PACKAGE/cache
    CONTEXT.getExternalMediaDirs()[0] /storage/emulated/0/Android/media/YOUR_PACKAGE
    CONTEXT.getExternalFilesDir("DIR_NAME) /storage/emulated/0/Android/data/YOUR_PACKAGE/files/DIR_NAME
    CONTEXT.getFilesDir() /data/user/0/YOUR_PACKAGE/files
    CONTEXT.getCacheDir() /data/user/0/YOUR_PACKAGE/cache
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search