Not sure if I understood your question completely.
When you change a theme, it gets stored in the personalization table as a key.
Table: SPERS_OBJ, PERS_KEY=/UI2/USER_PROFILE
You can change the selected themes and observe changes in the key.
You may have to debug ABAP code find out the other tables involved.