阅读背景:

偶遇DiskLruCache(缓存策略解析)

来源:互联网 

依据郭神的博客写了个小demo,详细的办法都卸载注释里了,先上后果图:




布局代码:

<LinearLayout xmlns:android="https://schemas.android.com/apk/res/android"
    xmlns:tools="https://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.disklrucache.MainActivity" >

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/showSize"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="25sp" />

            <Button
                android:id="@+id/read"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="缓存图片" />

            <Button
                android:id="@+id/remove"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="移除缓存图片" />
            
            <Button
                android:id="@+id/delete"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="删除全体缓存(包含日志文件)"/>

            <Button
                android:id="@+id/show"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="显示图片" />

            <ImageView
                android:id="@+id/img"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </ScrollView>

</LinearLayout><Li




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: