Android Context Get cachedJson(Context context, URI uri)

Here you can find the source of cachedJson(Context context, URI uri)

Description

cached Json

Declaration

private static String cachedJson(Context context, URI uri) 

Method Source Code

//package com.java2s;

import java.io.BufferedReader;
import java.io.IOException;

import java.io.InputStreamReader;

import java.net.URI;

import android.content.Context;

import android.util.Log;

public class Main {
    private static final String TAG = "SOHelper";

    private static String cachedJson(Context context, URI uri) {
        try {/*from  w ww  .  j  a  va2s.co  m*/
            StringBuffer json = new StringBuffer();
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    context.openFileInput(String.format("%d.json",
                            uri.hashCode()))));

            String line = null;
            while ((line = in.readLine()) != null) {
                json.append(line);
            }
            in.close();
            return json.toString();
        } catch (IOException ex) {
            Log.e(TAG, String.format("error reading cached %s", uri));
            return null;
        }
    }
}

Related

  1. readRaw(Context ctx, int res_id)
  2. loadImageFromAsset(Context context, String id)
  3. hasTelephony(@Nonnull Context context)
  4. getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs)
  5. getPath(final Context context, final Uri uri)
  6. cacheJson(Context context, URI uri, String jsonSource)
  7. getSharedPreferences(Context context)
  8. getAndroidDBDir(Context context)
  9. getAnimId(Context paramContext, String paramString)