美文网首页
Android储存记录

Android储存记录

作者: lmz14 | 来源:发表于2022-01-06 11:40 被阅读0次

一、内部存储

1、openFileInput、openFileOutput、getFilesDir

android.content.Context#openFileInput
android.content.Context#openFileOutput
android.content.Context#getFilesDir (注:返回files目录的绝对路径,通过openFileOutput被保存的文件放在files目录下)
文件保存路径:/data/data/你的应用程序的包名/files/

2、getCacheDir

android.content.Context#getCacheDir
文件保存路径:/data/data/你的应用程序的包名/cache/

3、getDownloadCacheDirectory 下载缓存内容目录

android.os.Environment#getDownloadCacheDirectory
文件保存路径:/data/cache

二、外部存储

1、私有目录
1)getExternalFilesDir

android.content.Context#getExternalFilesDir
文件保存路径:/storage/emulated/0/Android/data/你的应用程序的包名/files

2)getExternalCacheDir

android.content.Context#getExternalCacheDir
文件保存路径:/storage/emulated/0/Android/data/你的应用程序的包名/cache

2、公共目录
1)getExternalStorageDirectory

android.os.Environment#getExternalStorageDirectory
文件保存路径:/storage/emulated/0

2)getExternalStoragePublicDirectory

android.os.Environment#getExternalStoragePublicDirectory
获取公有目录下对应的类型文件夹
eg:
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
文件保存路径:/storage/emulated/0/Pictures

三、版本差异

版本差异.png
图片来源:Android 10 分区存储介绍及百度APP适配实践

参考资料:
1、Android 10 分区存储介绍及百度APP适配实践
2、关于 Android 的文件存储目录

相关文章

网友评论

      本文标题:Android储存记录

      本文链接:https://www.haomeiwen.com/subject/uyglcrtx.html