Fresco自定義路徑
阿新 • • 發佈:2018-12-20
/** * date:2018/12/3 * author:輝(家輝輝輝) * function:初始化fresco */ public class MyApp extends Application { @Override public void onCreate() { super.onCreate(); //設定自定義快取地址 DiskCacheConfig images = DiskCacheConfig.newBuilder(this) .setBaseDirectoryName("images")//設定資料夾名 .setBaseDirectoryPath(Environment.getDataDirectory())//設定快取路徑(sd) .build(); ImagePipelineConfig build = ImagePipelineConfig.newBuilder(this) .setMainDiskCacheConfig(images) .build(); Fresco.initialize(this,build); } }
如果想在其他路徑需要把setBaseDirectoryPath方法換成下面的方法(按照需求選一個)
.setBaseDirectoryPath(Environment.getDataDirectory())//設定快取路徑(sd)
.setBaseDirectoryPath(Environment.getExternalStorageState(file))//自定義路徑