0
public class Expense implements Parcelable, Serializable {
private String _amount, _amountVat, _dateOfExpense, _dateAdded, _datePaid, _expenseDescription;
private Boolean _paid;
private Bitmap _imageBitMap;

public Expense(){
    super();
}

This is my class, i read that you cannot store parcelable objects to external storage. Would it work with implementing Serializable by adding it to the class in which i have done ? I am not too sure on how to implement the save and load in this class either. I have been looking at other questions on here but I can't seem interpret them to apply to my application.

KPullet
  • 21
  • 3

1 Answers1

0

Purpose of parcalable is that some time we have our custom object that have large number of attributes and we need to send it to next activity sending all attributes seprately makes difficulties with parcalable you can do it easily.

For example you are trying to pass parcalable object to next activity create your object and pass it as

Intent intent = new Intent(MainActivity.this, NextActivity.class);
Boy boo = new Boy();
intent.putExtra("boo", boo);
startActivity(intent);

now in your next activity definetly you want to retrieve it that is prety simple again.

Boy boo = getIntent().getExtras().getParcelable("boo");
Nouman Ch
  • 4,023
  • 4
  • 29
  • 42
  • Hi thank you for your reply. This is not my problem. I have implemented the passing between activities. My question is how do i save that object to external storage and load it ? – KPullet Mar 10 '18 at 15:14
  • One way is converting the object to json string and save as text in external storage. Another way would be to use database. – Hussain Mar 10 '18 at 15:33
  • it is not recommended to store parcalable object as persistent. – Nouman Ch Mar 10 '18 at 15:37