提前加载,可以放在static{}中,当类被加载的时候创建,如:
static { sURLMatcher.addURI("mms_temp_file", "scrapSpace", MMS_SCRAP_SPACE); }
懒加载,当被使用的时候再去创建
private void buildReadContentValues() { if (mReadContentValues == null) { mReadContentValues = new ContentValues(2); mReadContentValues.put("read", 1); mReadContentValues.put("seen", 1); } }
类似的还有单例模式的不同创建方式:懒汉式,饿汉式。