SHARE
TWEET

Untitled

a guest May 23rd, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. String key = "Key";
  2.                 List<CartProductListPojo> cartProductListPojos = new ArrayList();
  3.                 cartProductListPojos.add(new CartProductListPojo( getItemId.getProductImage(),
  4.                         getItemId.getProductName(),
  5.                         getItemId.getProductBrandName(), getItemId.getProductCategory(), 1,
  6.                         getItemId.getProductPrice()));
  7.  
  8.                 SharedPreferences shref;
  9.                 SharedPreferences.Editor editor;
  10.                 shref = context.getSharedPreferences("Name", Context.MODE_PRIVATE);
  11.  
  12.                 Gson gson = new Gson();
  13.                 String json = gson.toJson(cartProductListPojos);
  14.  
  15.                 editor = shref.edit();
  16.                 /*editor.remove(key).commit();*/
  17.                 editor.putString(key, json);
  18.                 editor.commit();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top