Android Get Application's 'Home' Data Directory

后端 未结 3 2113
情书的邮戳
情书的邮戳 2020-12-01 00:15

A simple question, relating to the default \'home\' directory when an app writes to the internal memory. By default, any files created are placed by the OS (2.2) in:

相关标签:
3条回答
  • 2020-12-01 00:26

    To get the path of file in application package;

    ContextWrapper c = new ContextWrapper(this);
    Toast.makeText(this, c.getFilesDir().getPath(), Toast.LENGTH_LONG).show();
    
    0 讨论(0)
  • 2020-12-01 00:43

    Of course, never fails. Found the solution about a minute after posting the above question... solution for those that may have had the same issue:

    ContextWrapper.getFilesDir()
    

    Found here.

    0 讨论(0)
  • 2020-12-01 00:44

    You can try Context.getApplicationInfo().dataDir if you want the package's persistent data folder.

    getFilesDir() returns a subroot of this.

    0 讨论(0)
提交回复
热议问题