如何在另一个公共类中将JSONObject添加到Global JSONArray

时间:2015-12-31 17:30:36

标签: java android arrays global-variables jsonobject

我有一个问题或者更好的困境。我必须将JSONObject添加到Global JSONArray,稍后我将从另一个活动中获取此数组。什么是更好的解决方案?

            JSONObject jsonObject = new JSONObject();

            try {
                jsonObject.put("strefa", strefa);
                jsonObject.put("adres", adres);
                jsonObject.put("kryteria", kryteria);
                jsonObject.put("telefon", telefon);
                jsonObject.put("data", data);
            } catch (Exception e) {
                e.printStackTrace();
            }

            GlobalConfig.JsonArray.put(jsonObject); // this is public static JSONArray JsonArray = new JSONArray();

或更好的是在GlobalConfig类中使用私有对象创建一个公共方法?

0 个答案:

没有答案