android app 缓存路径

 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

猜你喜欢

转载自antwei.iteye.com/blog/2105992