private int readFromLocal(String accPath) { // isAlreadyReadLocal = true; String path = accPath + LOCAL_CONFIG_FILENAME; if (!FileOperation.fileExists(path)) { readConfig(); return -1; } byte[] buf = FileOperation.readFromFileV2(path, 0, -1); if (Util.isNullOrNil(buf)) { readConfig(); return -2; } String info = new String(buf); if (Util.isNullOrNil(info)) { readConfig(); return -3; } Log.d(TAG, "readFromLocal info " + info); cfgStg.set(ConstantsStorage.USERINFO_SERVER_CONFIG_INFO, info); isAlreadyReadLocal = true; super.doNotify(info); return 0; }
private void readConfig() { String info = (String) cfgStg.get(ConstantsStorage.USERINFO_SERVER_CONFIG_INFO); Log.d(TAG, "readConfig xml " + info); if (!Util.isNullOrNil(infoCache)) { super.doNotify(info); } }
public static boolean writeConfigToFile(String info) { if (Util.isNullOrNil(info)) { return false; } try { Map<String, String> maps = KVConfig.parseXml(info, "voip", null); if (maps == null) { return false; } } catch (Exception e) { e.printStackTrace(); return false; } boolean flag = false; File filePath = new File(ConstantsStorage.DATAROOT_MOBILEMEM_PATH); if (!filePath.exists()) { filePath.mkdirs(); } FileWriter fw = null; try { fw = new FileWriter(ConstantsStorage.DATAROOT_MOBILEMEM_PATH + LOCAL_CONFIG_FILENAME); fw.write(info); flag = true; if (fw != null) { fw.close(); } } catch (Exception e) { e.printStackTrace(); } finally { if (fw != null) try { fw.close(); } catch (IOException e) { e.printStackTrace(); } } return flag; }