Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Does R.Resource ID changes in runtime

Tags:

android

I have number of drawables to select in a View. When the user selects one of the drawable and on next time when the app is launch , I have to show only the selected drawable.

Is it good to store the Resource ID in shared preference and retrieve the selected drawable using Resource ID next time when the app is launched.?

like image 679
Libin Avatar asked Apr 17 '14 03:04

Libin


1 Answers

All the R class related ids are generated at compile time so they won't change at runtime. There's nothing stopping you from storing this IDs in SharedPreferences, however, there's no gain whatsoever. It's almost always faster just to reference the R.drawable.x related id.

like image 99
ajacian81 Avatar answered Oct 13 '22 01:10

ajacian81