java - Is it safe to serialize a class instance with a resource reference attribute? -


i serialize object like:

   class dog implements serializable{         public string name;        public int icondrawable;     } 

the icondrawable int pointing drawable resource r.java.

so can make dog this:

dog dog = new dog(); dog.name= "barky"; dog.icondrawable = r.drawable.dog_icon; //portrait of dog instance 

my question is:

is safe serialize object? icondrawable final number , do same drawable when de-serialize? or reference change on app startup or app termination?

or should store name of drawable in string attribute field , use getidentifier? (little more complicated works sure)

r.java generated @ build time. change if modify (add, remove, etc) resources or possibly if new version of android build tools used build project.

that being said safe serialize/deserialize resource id if using transport object activity/fragment or similar during runtime.

however, if serializing persistence not safe ids can change mentioned between application builds. in case best use getidentifier.


Comments

Popular posts from this blog

Redirect to a HTTPS version using .htaccess -

Unlimited choices in BASH case statement -

javascript - jQuery: Add class depending on URL in the best way -