欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

android app 缓存路径

程序员文章站 2022-07-03 16:22:20
...

 android app 应用缓存路径如果在内部存储是在应用安装目录

在外部存储是位子为app数据目录。这两类存储都不会出现卸载应用后残留垃圾的问题

其中在外部存储缓存时部分机型会独占存储设备导致应用崩溃。

dir = this.getExternalCacheDir().getAbsolutePath();

        Log.i("打印cache", dir);

        dir = this.getFilesDir().getPath();

        Log.i("打印filesdir", dir);

        dir = Environment.MEDIA_MOUNTED;

        Log.i("打印filesdir", dir);

        dir = Environment.getExternalStorageState();

        Log.i("打印Enviroment state", dir);

        dir = Environment.getRootDirectory().getAbsolutePath();

        Log.i("打印Enviroment root", dir);

 

        dir = getCacheDir().getPath();

        Log.i("打印 inner cache", dir);

 

        String cachePath = Environment.MEDIA_MOUNTED.equals(Environment

                .getExternalStorageState()) || !Environment.isExternalStorageRemovable() ? getExternalCacheDir()

                .getPath() : getCacheDir().getPath();

        Log.i("打印 External", cachePath);

 

08-19 16:05:12.296  17190-17190/com.antwei.mychat I/打印cache﹕ /storage/emulated/0/Android/data/com.antwei.mychat/cache

08-19 16:05:12.657  17190-17190/com.antwei.mychat I/打印filesdir﹕ /data/data/com.antwei.mychat/files

08-19 16:05:12.657  17190-17190/com.antwei.mychat I/打印filesdir﹕ mounted

08-19 16:05:12.657  17190-17190/com.antwei.mychat I/打印Enviroment state﹕ mounted

08-19 16:05:12.657  17190-17190/com.antwei.mychat I/打印Enviroment root﹕ /system

08-19 16:05:12.657  17190-17190/com.antwei.mychat I/打印 inner cache﹕ /data/data/com.antwei.mychat/cache

08-19 16:05:12.657  17190-17190/com.antwei.mychat I/打印 External﹕ /storage/emulated/0/Android/data/com.antwei.mychat/cache