관리 메뉴

개발새발 블로그

저장된 Json 데이터 읽기 본문

android

저장된 Json 데이터 읽기

SeanBlog 2019. 12. 11. 14:52
public String loadJSONFromAsset() {
        String json = null;
        try {
 
            InputStream is = getAssets().open("파일명.json");
            int size = is.available();
            byte[] buffer = new byte[size];
            is.read(buffer);
            is.close();
            json = new String(buffer, "UTF-8");
 
        } catch (IOException ex) {
            ex.printStackTrace();
            return null;
        }
        return json;
 
    }
 
 
JSONObject obj = new JSONObject(json_return_by_the_function); 
//JSONObject를 파싱하여 원하는 대로 리스트에 그려주면 됩니다.
Comments