I need to store the userid in a shared preference and use it in a second activity, but I don't know how to do it. How can I only store the id and recall it in an second activity?
Here is my code:
    JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    try {
                        Boolean esito = response.getBoolean("Esito");
                        if (esito) {
                            JSONArray jsonArray = response.getJSONArray("Dati");
                            Log.d("JSON", String.valueOf(esito));
                            for (int i = 0; i < jsonArray.length(); i++) {
                                JSONObject dato = jsonArray.getJSONObject(i);
                                String id = dato.getString("id");
                                String fullname = dato.getString("fullname");
                                String username = dato.getString("username");
                                String password = dato.getString("password");
                                //mTextViewResult.append(id + ", " + fullname +  ", " + username +  ", " + password + "\n\n");
                                startActivity(new Intent(getApplicationContext(),LoggedActivity.class));
                            }
                        } else {
                            Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                        Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
                    }
                }
            }
 
     
     
    