Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  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();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement