assets目录下存放的原生资源文件,通过getAssets()方法获取.

使用:

InputStream inputStream;
            try {
                inputStream = getAssets().open("data/chat.isp");
                String json = StringUtil.readTextFile(inputStream);
                JSONArray array = new JSONArray(json);
                backModel result = null;
                for (int i = 0; i < array.length(); i++) {
                    result = new backModel();
                    result.setTime(array.getJSONObject(i).getString("time"));
                    result.setContent(array.getJSONObject(i).getString("content"));
                    
backModels.add(result);
                }
            } catch (IOException e) {
                e.printStackTrace();
            } catch (JSONException e) {
                e.printStackTrace();
            }

其中数据存在于assets\data\chat.isp文件中:

[{"time":"14:25:29","content":"在么?,","type":"1"},{"time":"14:26:18","content":"嗯,在的,","type":"2"}]

可以存储一些不更改的不用编译的数据

相关文章:

  • 2022-03-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2021-12-01
猜你喜欢
  • 2021-08-26
  • 2022-12-23
  • 2021-08-30
  • 2021-06-18
  • 2022-01-08
  • 2021-08-12
  • 2022-12-23
相关资源
相似解决方案