To store various types of files such as .txt, .json, etc, you first need to create an Assets folder , which you will put your archives in.
To create a Assets Folder just click on your project with the right mouse button and follow this path:
New-> Folder-> Assets Folder
NowthatyouhaveanAssetsFolderjustgointoitanddragthefilesyouwant.Toenteritjustfollowthedirectionsofthenextimage:
Nowyourfilealreadyappearsintheproject.
Toreadthefile,youcandothis:
publicStringloadJSONFromAsset(StringnomeArquivo){Stringjson=null;try{InputStreamis=context.getAssets().open(nomeArquivo);intsize=is.available();byte[]buffer=newbyte[size];is.read(buffer);is.close();Stringtexto=newString(buffer,"UTF-8");
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
return texto;
}