From 6727ca2c427069e3ca158b6f186e23e525cbaa9a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Aug 2015 09:36:32 +0800 Subject: [PATCH] modify files Summary: modify file #123 #126 #122 #121 #115 modify file Reviewers: nan.li Reviewed By: nan.li Differential Revision: http://pha.cobub.cn/D91 --- .../SDK/src/com/wbtech/ums/CommonUtil.java | 3 ++- .../SDK/src/com/wbtech/ums/SaveInfo.java | 20 +++++++++---------- sdk/android_sdk/Sample/AndroidManifest.xml | 2 +- .../com/wbtech/test_sample/MainActivity.java | 8 +++++--- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/sdk/android_sdk/SDK/src/com/wbtech/ums/CommonUtil.java b/sdk/android_sdk/SDK/src/com/wbtech/ums/CommonUtil.java index 4606db00..05cdb797 100644 --- a/sdk/android_sdk/SDK/src/com/wbtech/ums/CommonUtil.java +++ b/sdk/android_sdk/SDK/src/com/wbtech/ums/CommonUtil.java @@ -52,7 +52,8 @@ public static void saveInfoToFile(String type, JSONObject info, newdata.put(0, info); JSONObject jsonObject = new JSONObject(); jsonObject.put(type, newdata); - Thread t = new SaveInfo(context, jsonObject); + String cacheFile = context.getCacheDir()+"/cobub.cache"; + Thread t = new SaveInfo( jsonObject,cacheFile); t.run(); } catch (Exception e) { diff --git a/sdk/android_sdk/SDK/src/com/wbtech/ums/SaveInfo.java b/sdk/android_sdk/SDK/src/com/wbtech/ums/SaveInfo.java index 04a2cfb0..6d0a28c9 100644 --- a/sdk/android_sdk/SDK/src/com/wbtech/ums/SaveInfo.java +++ b/sdk/android_sdk/SDK/src/com/wbtech/ums/SaveInfo.java @@ -32,14 +32,14 @@ * @author duzhou.xu */ class SaveInfo extends Thread { - public Context context; public JSONObject object; private final String tag = "SaveInfo"; + private String path = ""; - public SaveInfo(Context context, JSONObject object) { + public SaveInfo( JSONObject object,String path) { super(); this.object = object; - this.context = context; + this.path = path; } @Override @@ -47,14 +47,14 @@ public void run() { super.run(); File file; - String cacheFile = context.getCacheDir()+"/cobub.cache"; - CobubLog.d(tag,"Save cache file "+cacheFile); + + CobubLog.d(tag,"Save cache file "+path); CobubLog.d(tag,"json data "+object.toString()); JSONObject existJSON = null; try { - file = new File(cacheFile); + file = new File(path); if (file.exists()) { CobubLog.i(tag, "file exist " + file.getAbsolutePath()); @@ -66,10 +66,10 @@ public void run() { // if (file.length() > 1024 * 1024) { file.delete(); - file = new File(cacheFile); + file = new File(path); file.createNewFile(); } - FileInputStream in = new FileInputStream(cacheFile); + FileInputStream in = new FileInputStream(path); StringBuffer sb = new StringBuffer(); int i = 0; @@ -97,7 +97,7 @@ public void run() { } } FileOutputStream fileOutputStream = new FileOutputStream( - cacheFile, false); + path, false); fileOutputStream.write(existJSON.toString().getBytes()); fileOutputStream.flush(); fileOutputStream.close(); @@ -115,7 +115,7 @@ public void run() { jsonObject.put("appkey", AppInfo.getAppKey()); FileOutputStream fileOutputStream = new FileOutputStream( - cacheFile, false); + path, false); fileOutputStream.write(jsonObject.toString().getBytes()); fileOutputStream.flush(); fileOutputStream.close(); diff --git a/sdk/android_sdk/Sample/AndroidManifest.xml b/sdk/android_sdk/Sample/AndroidManifest.xml index 0a3edeb1..5ff4496b 100644 --- a/sdk/android_sdk/Sample/AndroidManifest.xml +++ b/sdk/android_sdk/Sample/AndroidManifest.xml @@ -34,7 +34,7 @@ + android:value="fa21d3716499a7a6747b63cad6a83778" />