編輯:關於Android編程
這是在一家工作過四個月的比利時公司時寫的。
當時忙於戶口調動的事兒,僅做了兩個項目,就離開了。
還是很感謝這家公司,戶口的調動除了我的中級職稱,也得到了這家公司老總的全力支持,遺憾沒能給予她更多的回報。
再次感謝謝。
這裡先挖個坑,後續有時間再填!
開始填坑:
package com.dday.dataaccesslayer.utils.helper;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.Context;
import com.dday.dataaccesslayer.utils.StorageServiceFactory;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public class JsonHelper {
public static T getEntityFromJson(String fromJsonStr, Class classOfT) throws JSONException {
GsonBuilder gsonb = new GsonBuilder();
gsonb.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE);
DateDeserializer ds = new DateDeserializer();
gsonb.registerTypeAdapter(Date.class, ds);
Gson gson = gsonb.create();
JSONObject j = new JSONObject(fromJsonStr);
return gson.fromJson(j.toString(), classOfT);
}
public static T getEntityFromInterStorage(Context context, String jsonFilePath, String charset, Class classOfT) throws JSONException, FileNotFoundException, UnsupportedEncodingException, IOException {
String jsonContent = InterStorageHelper.readInternal(context, jsonFilePath, charset);
return getEntityFromJson(jsonContent, classOfT);
}
public static T getEntityFromInterStorage(Context context, String jsonFilePath, Class classOfT) throws JSONException, FileNotFoundException, UnsupportedEncodingException, IOException {
return getEntityFromInterStorage(context, jsonFilePath, "UTF-8", classOfT);
}
public static T getEntityFromExterPrivateStorage(Context context, String jsonFilePath, String charset, Class classOfT) throws JSONException, FileNotFoundException, UnsupportedEncodingException, IOException {
String jsonContent = StorageServiceFactory.getSharedInstance().getExterStorageService(context).getPrivateFile(jsonFilePath, charset);
return getEntityFromJson(jsonContent, classOfT);
}
public static T getEntityFromExterPrivateStorage(Context context, String jsonFilePath, Class classOfT) throws JSONException, FileNotFoundException, UnsupportedEncodingException, IOException {
String jsonContent = StorageServiceFactory.getSharedInstance().getExterStorageService(context).getPrivateFile(jsonFilePath, "UTF-8");
return getEntityFromJson(jsonContent, classOfT);
}
}
此類用到了GSON庫。
其中有一些其它相關類型,這裡不便提供,僅供大家參考其中的邏輯。
Android 實現仿網絡直播彈幕功能詳解及實例
Android 網絡直播彈幕  
AndroidUI組件之ActionBar--基於下拉的導航方式
在上一篇關於ActionBar的博文中,我們知道了ActionBar是Android3.0的重要更新之一。本篇博文就來寫一個開發中經常用到的例子。用Act
Android5.0美不勝收的新特性 Material Design
Google提出了全新的設計規范Material Design,扁平化的設計,加上明亮的色彩,有一種美不勝收的感覺。Material Design翻譯過來叫做&ldquo
Android中通過Messenger與Service實現進程間雙向通信
Android中的Service和其調用者既可以在同一個App中,也可以在不同的App。如果Service在App1中,而調用Service的客戶端在App2中,那麼我們