File: HardCodedSdCardPath.md

package info (click to toggle)
error-prone-java 2.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 23,204 kB
  • sloc: java: 222,992; xml: 1,319; sh: 25; makefile: 7
file content (14 lines) | stat: -rw-r--r-- 692 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Your code should not reference the `/sdcard` path directly, which is
platform-dependent. You should use
`Environment.getExternalStorageDirectory().getPath()` instead.

Similarly, do not reference the `/data/data/` path directly, as it can vary in
multi-user scenarios. You should use `Context.getFilesDir().getPath()` instead.

For more information, please see the documentation for
[android.os.Environment](http://developer.android.com/reference/android/os/Environment.html)
and
[android.content.Context](http://developer.android.com/reference/android/content/Context.html).

This check is an adaptation of the `SdCardPath` rule of
[Android Lint](http://tools.android.com/tips/lint-checks).