Read Asset JSON File - Android App

Android examples for App:Assets File

Description

Read Asset JSON File

Demo Code


//package com.java2s;

import android.content.res.AssetManager;
import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static String AssetJSONFile(String filename, AssetManager manager)
            throws IOException {
        String json = null;//from   ww w  .  j a va2  s  .  co  m
        InputStream is = manager.open(filename);
        int size = is.available();
        byte[] buffer = new byte[size];
        is.read(buffer);
        is.close();
        json = new String(buffer, "UTF-8");
        return json;
    }
}

Related Tutorials