Quick question : Do my view IDs (in integer) chang...
# android
s
Quick question : Do my view IDs (in integer) change after every clean install of the app? Example : I've given an id to the card view via XML (let's say it's called safeCard) Now this view has an integer ID to it. I'm saving this on my database and retrieving it for a user. So when I reinstall my app, does safeCard's id change?
😶 2
z
This has nothing to do with kotlin, but 1. No, resource ids (view and otherwise) are generated at build time, not install time. 2. Saving view ids to your database smells bad. The use case for database IDs is typically very different from that of view IDs , and sharing them sounds like your code is conflating concepts and probably much too tightly coupled.
e
if you install a new build (upgrade), id integers may be different than before.
d
I’m so confusing why you want to save view_id to your database. But anyway, if you do want this, try to save resource name to your db and call resources#`getIdentifier` to get view_id
s
@Danny Zhang Im saving some form data from the users. I have a custom checkable card view so based on the user's submission, I want to set the card to be checked when they want to modify some data. But yeah I felt this was a bad way to do things so I'm using their answers as identifiers because these answers are static and predefined options. @ephemient @Zach Klippenstein (he/him) [MOD] thanks a lot for the help guys. Will be cautious enough to not post non-kotlin related stuff hereon.