Scaling to be the same size on every phone

Ok I’m just struggling to do this. So I know it will involve displayDensity but I either don’t understand how this is documented or I’m doing something wrong. So I created my app on a 441 dpi screen-displayDensity value of 2.625. I am thinking that I will need to come up with some value that I multiply every graphical element by. I’m just overall confused on how I would go about doing this. I am thinking it would then be when displayDensity is 2.625, the value should equal 1, so I have

float val = displayDensity*(1/2.625);

but this is not working.
Any help is appreciated

EDIT: I might have actually done it right but was calling the above just in nothingness but after moving it into a function, it is currently working. Unsure of how this will work on other screen resolutions though so if you see a lapse in my reasoning please let me know!

EDIT: I have finally been able to test it on a phone with a different resolution and it is not working at all. So what do I need to know?

@CrispyCabot===

your error is thinking to YOUR phone: all phones are classified by android (6 classes) and the “middle” is 160dpi, which means that your phone is, for android, XXHdpi; in this case if you have some rect of 100px (on your phone) it appears quite x3 on a Mdpi phone…In short: consider that 160 dpi = 1, get the screen density (as you do) and multiply or divide according to the result (some square of 100px for 160 must be multiplied on your phone and divided if it s a ldpi phone).