Java Code Examples for android.content.ContextWrapper#getAssets()
The following examples show how to use
android.content.ContextWrapper#getAssets() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KcaUtils.java From kcanotify_h5-master with GNU General Public License v3.0 | 6 votes |
public static JsonObject getJsonObjectFromAsset(Context context, String name, KcaDBHelper helper) { ContextWrapper cw = new ContextWrapper(context); JsonObject data = null; AssetManager am = cw.getAssets(); try { AssetManager.AssetInputStream ais = (AssetManager.AssetInputStream) am.open(name); byte[] bytes = ByteStreams.toByteArray(ais); data = new JsonParser().parse(new String(bytes)).getAsJsonObject(); ais.close(); } catch (IOException e1) { e1.printStackTrace(); if (helper != null) helper.recordErrorLog(ERROR_TYPE_DATALOAD, name, "getJsonObjectFromStorage", "1", getStringFromException(e1)); } return data; }
Example 2
Source File: KcaUtils.java From kcanotify_h5-master with GNU General Public License v3.0 | 6 votes |
public static JsonArray getJsonArrayFromAsset(Context context, String name, KcaDBHelper helper) { ContextWrapper cw = new ContextWrapper(context); JsonArray data = new JsonArray(); AssetManager am = cw.getAssets(); try { AssetManager.AssetInputStream ais = (AssetManager.AssetInputStream) am.open(name); byte[] bytes = ByteStreams.toByteArray(ais); data = new JsonParser().parse(new String(bytes)).getAsJsonArray(); ais.close(); } catch (IOException e1) { e1.printStackTrace(); if (helper != null) helper.recordErrorLog(ERROR_TYPE_DATALOAD, name, "getJsonArrayFromStorage", "1", getStringFromException(e1)); } return data; }
Example 3
Source File: KcaUtils.java From kcanotify with GNU General Public License v3.0 | 6 votes |
public static JsonObject getJsonObjectFromAsset(Context context, String name, KcaDBHelper helper) { ContextWrapper cw = new ContextWrapper(context); JsonObject data = null; AssetManager am = cw.getAssets(); try { AssetManager.AssetInputStream ais = (AssetManager.AssetInputStream) am.open(name); byte[] bytes = ByteStreams.toByteArray(ais); data = new JsonParser().parse(new String(bytes)).getAsJsonObject(); ais.close(); } catch (IOException e1) { e1.printStackTrace(); if (helper != null) helper.recordErrorLog(ERROR_TYPE_DATALOAD, name, "getJsonObjectFromStorage", "1", getStringFromException(e1)); } return data; }
Example 4
Source File: KcaUtils.java From kcanotify with GNU General Public License v3.0 | 6 votes |
public static JsonArray getJsonArrayFromAsset(Context context, String name, KcaDBHelper helper) { ContextWrapper cw = new ContextWrapper(context); JsonArray data = new JsonArray(); AssetManager am = cw.getAssets(); try { AssetManager.AssetInputStream ais = (AssetManager.AssetInputStream) am.open(name); byte[] bytes = ByteStreams.toByteArray(ais); data = new JsonParser().parse(new String(bytes)).getAsJsonArray(); ais.close(); } catch (IOException e1) { e1.printStackTrace(); if (helper != null) helper.recordErrorLog(ERROR_TYPE_DATALOAD, name, "getJsonArrayFromStorage", "1", getStringFromException(e1)); } return data; }