The native resource files stored under the assets directory are obtained through the Getassets () method.
Use:
InputStream InputStream; Try{InputStream= Getassets (). Open ("Data/chat.isp"); String JSON=Stringutil.readtextfile (InputStream); Jsonarray Array=NewJsonarray (JSON); Backmodel result=NULL; for(inti = 0; I < Array.Length (); i++) {result=NewBackmodel (); 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 (); }
Where the data exists in the Assets\data\chat.isp file:
[{"Time": "14:25:29", "Content": "In?,", "type": "1"},{"Time": "14:26:18", "Content": "Well, in,", "type": "2"}]
You can store some data that doesn't change without compiling.
Android's assets resources