Skip to content

Saved jsonStringList as a textfile and had problems loading  #2

@kehems

Description

@kehems

Saved jsonStringList as a textfile in the asset folde and had problems loading.

see code:

private void NLevelExpandableListView(){
// String jsonStringList = getAssetJsonData(getApplicationContext());

    String json = "";
    try {
        InputStream inputStream = getAssets().open("test.txt");
        int size = inputStream.available();
        byte[] buffer = new byte[size];
        inputStream.read(buffer);
        inputStream.close();
        json = new String(buffer);

    }  catch (IOException ex){
        ex.printStackTrace();
    }

    Log.i("Control", json);
    String jsonStringList = "json";

Logcat display.....
2020-01-24 14:40:03.702 18888-18888/com.example.orcoa I/Control: [{"title": "Class 1 Accounts of Durable Resources", " +
""children":[{"title":" 10 Capital", " +
""children":[{"title":"Extended Child 111", " +
""children":[{"title":"Super Extended Child 1111"," +
""children":[]}]},{"title":"Extended Child 112"," +
""children":[]},{"title":"Extended Child 113","children":[]}]}," +
"{"title":"Child 12", " +
""children":[{"title":"Extended Child 121"," +
""children":[]},{"title":"Extended Child 122", " +
""children":[]}]},{"title":"Child 13", "children":[]}]}, " +

                "{\"title\":\"Class 2\", \"children\":" +
                "[{\"title\":\"Child 21\", \"children\":" +
                "[{\"title\":\"Extended Child 211\", \"children\":[]}," +
                "{\"title\":\"Extended Child 212\", \"children\":[]}," +
                "{\"title\":\"Extended Child 213\", \"children\":[]}]}," +
                "{\"title\":\"Child 22\", \"children\":" +
                "[{\"title\":\"Extended Child 221\", \"children\":[]}," +
                "{\"title\":\"Extended Child 222\", \"children\":[]}]}," +
                "{\"title\":\"Child 23\", \"children\":[]}]}," +


                "{\"title\":\"Class 3\",\"children\":[]}]

App does work as before. What could be wrong. Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions