45

Where is the temp folder located on Android phones?

Floern
  • 33,559
  • 24
  • 104
  • 119
  • What do you mean by temp folder, generally Android applications have their own isolated storage provided by the system. What are you storing in a 'temp' folder? – Quintin Robinson Mar 02 '10 at 16:31
  • It might be good to migrate this question to https://android.stackexchange.com – pevik Jan 17 '18 at 05:39
  • @pevik No, because we are talking about file-only temp directories. Something that is used in development. – Gaurav Mall Aug 25 '19 at 08:46
  • @GauravMall but https://android.stackexchange.com/ is IMHO also for development. At least there are similar questions. – pevik Aug 26 '19 at 16:50
  • @pevik Well, could be. Anyways I don't agree. That's okay you can have a different opinion on the matter :) – Gaurav Mall Aug 26 '19 at 18:06

4 Answers4

37

The temporary directory is /data/local/tmp.

I've seen some comments that claim you need to be rooted to access it but I'm not sure that's true. Whilst it is true that you need root to freely access /data, this is not required for /data/local/tmp.

I have verified this on Android 5.1.1.

starfry
  • 9,273
  • 7
  • 66
  • 96
  • 2
    Tested on Android 4.x and 7.x and on both it's working fine. It's possible to create subdirectories (using `adb shell`) and store screenshots in that temp directory and then pull them from the device using `adb`. Tested on non-rooted devices. – David Ferenczy Rogožan Dec 01 '17 at 14:02
  • How about is the premission? Will it be accessed by any app? – Yeung Mar 31 '20 at 05:17
14

I believe what you're looking for is getCacheDir()!

Hein du Plessis
  • 3,305
  • 6
  • 34
  • 51
10

Reading this post from the android developers google group leads me to believe that there is not 1 global temp directory, and each application is expected to maintain their own temporary files.

snctln
  • 12,175
  • 6
  • 45
  • 42
2

The files downloaded using createTempFile() are stored in folder:

/data/data/YOURapp/cache/
Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
tariq101
  • 127
  • 2
  • 6