How to display image from json in apk?

Hello, please help a newbie android programmer.
I'm doing an application with tests. My app displays the question and answers. I want to add the functionality of adding questions still photo. Questions are taken from the json file. My thoughts are to add another pair key-value in json file already with pictures. I guess images are best kept in the drawable folder. And the questions begin
1. How to specify the path to this picture file in json?
{
"question": "What is depicted in the illustration of the coastal information sign?",
"answers": [
"The maximum speed wodoslawsky courts 15 km/h",
"Width of the channel is 15 m",
"The depth of the river 15 m",
"The height of the surface of the transition 15 m"
],
"correct_answer": 3,
"question_category": "1",
"picture": "/res/drawable/v1b1.jpg" <------- this is the title of the picture. "this path is a relative path to it?
}
2. How to display images from json to the questions, and that they scale appropriately.

Recently started to study apk so many stupid questions.
5df35e3985e6e707622525.png

3. Trying to parse a json string with a photo picture similar how to understand others. When you run prilagodi lost questions.

public void parseJson(String jsonData) {
 try {

 JsonObjMain JSONObject = new JSONObject(jsonData);
 JSONArray jsonArray = jsonObjMain.getJSONArray(AppConstants.JSON_KEY_QUESTIONNAIRY);

 for (int i = 0; i < jsonArray.length(); i++) {
 JSONObject jsonObj = jsonArray.getJSONObject(i);

 //String picture = jsonObj.getString(AppConstants.JSON_KEY_PICTURE);
 String question = jsonObj.getString(AppConstants.JSON_KEY_QUESTION);
 int correctAnswer = Integer.parseInt(jsonObj.getString(AppConstants.JSON_KEY_CORRECT_ANS));
 String categoryId = jsonObj.getString(AppConstants.JSON_KEY_CATEGORY_ID);


 Log.d("TAG", categoryId.toString());

 JsonArray2 JSONArray = jsonObj.getJSONArray(AppConstants.JSON_KEY_ANSWERS);
 ArrayList<String> contents = new ArrayList<>();
 ArrayList<String> backgroundColors = new ArrayList<>();
 for (int j = 0; j < jsonArray2.length(); j++) {
 String item_title = jsonArray2.get(j).toString();
contents.add(item_title);
backgroundColors.add(AppConstants.COLOR_WHITE);
}
 if (mCategoryId.equals(categoryId)) {
 mItemList.add(new QuizModel(question, contents, correctAnswer, categoryId, backgroundColors));
}
}

 mQuestionsCount = mItemList.size();
Collections.shuffle(mItemList);

hideLoader();
updateQuestionsAndAnswers();

 } catch (JSONException e) {
e.printStackTrace();
showEmptyView();
}
 }


This line kills //String picture = jsonObj.getString(AppConstants.JSON_KEY_PICTURE); if raccomandati
April 3rd 20 at 17:48
0 answer

Find more questions by tags JavaAndroidJSON