Where is the temp folder on Android devices?
Asked Answered
P

4

47

Where is the temp folder located on Android phones?

Procora answered 2/3, 2010 at 16:26 Comment(5)
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?Frontpage
It might be good to migrate this question to android.stackexchange.comKaffir
@Kaffir No, because we are talking about file-only temp directories. Something that is used in development.Prud
@GauravMall but android.stackexchange.com is IMHO also for development. At least there are similar questions.Kaffir
@Kaffir Well, could be. Anyways I don't agree. That's okay you can have a different opinion on the matter :)Prud
Z
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.

Zacharia answered 2/3, 2010 at 16:39 Comment(2)
Link is dead/spam/bannedPeril
See here: quora.com/Where-should-I-find-temp-files-in-Android-mobilesApomixis
S
39

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.

Salter answered 12/12, 2016 at 16:46 Comment(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.Victoir
How about is the premission? Will it be accessed by any app?Joniejonina
B
15

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

Breastbeating answered 14/2, 2011 at 13:3 Comment(3)
cache ≠ tmp, caches are useful to store around, whereas temp files are meant to be deleted.Exhortation
Android has the functions File.createTempFile() and File.createTempDirectory(), but they also create files in Context.getCacheDir()Surah
And how can i call this function?Pleuropneumonia
Z
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.

Zacharia answered 2/3, 2010 at 16:39 Comment(2)
Link is dead/spam/bannedPeril
See here: quora.com/Where-should-I-find-temp-files-in-Android-mobilesApomixis
C
2

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

/data/data/YOURapp/cache/
Callum answered 3/11, 2020 at 14:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.