i have a database with a column named "items" , i put my JsonString in that column. i want to grab data from array in a for loop but it is not giving me data here is my code :
dbConnector = new DbConnector(getContext(),null,null,1);
Cursor c = dbConnector.get().rawQuery("SELECT * FROM factors",null);
while (c.moveToNext()){
String name = c.getString(c.getColumnIndex("name"));
String items = c.getString(c.getColumnIndex("items"));
String itemsEncoded = null;
int priceEncoded = 0;
int amount = 0;
try {
JSONArray mJsonArray = new JSONArray(items);
JSONObject mJsonObject;
Log.e("JSON ARRAY",mJsonArray.length() + "");
for (int i = 0; i < mJsonArray.length(); i++) {
mJsonObject = mJsonArray.getJSONObject(i);
mJsonObject.getString("product_id");
priceEncoded += Integer.parseInt(mJsonObject.getString("price"));
amount += Integer.parseInt(mJsonObject.getString("number"));
itemsEncoded += mJsonObject.getString("product_name") + " - " + mJsonObject.getString("price") + " ????? " + " - " + mJsonObject.getString("number")+ " ???" + "\n";
}
}catch (JSONException e){
Log.e("ERROR",e.getMessage());
}
list.add(new FactorObject(name,priceEncoded + "",amount,itemsEncoded));
}
recyclerView = view.findViewById(R.id.factorRecycler);
adapter = new FactorsAdapter(getContext(),list);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
variables "priceEncoded", "amount","itemsEncoded" are all null and it seems that for loop is not working
JSON example: JSON Example
and also i am 100% sure that my database is full