title: Storing and initializing universally used values for an android App (example: Screen density)
body: <p>I'm pretty new to programming for Android so if this is the wrong way to go about it anyway, feel free to comment about my bad practice.</p>
  <p>In my App, I have different Activities that use the same values. Also, I have some classes that have static methods, used in multiple activities. For example to generate ImageViews from a &quot;URL&quot;.</p>
  <p>One of the values I would use in almost all of my app is this snippet: (taken from <a href="https://stackoverflow.com/questions/5255184/android-and-setting-width-and-height-programmatically-in-dp-units">another question on SO</a>)</p>
  <pre><code>getApplicationContext().getResources().getDisplayMetrics().density
  </code></pre>
  <p>This particular value for example is needed for every activity. But it's also needed for the same task. So I use a static class that has the appropriate method for that task. However, that static class does not have a &quot;getApplicatioContext&quot;, obviously. So I would need to store the value somewhere else.</p>
  <p><strong>My question is</strong>, is there a designated or at least optimal or clean way to store such values and initialize them on App startup?</p>
  <p>As I understand it, I could use the &quot;onCreate&quot;-Method of my launch activity and initialize some static class or something like that. However, that seems a little dirty to me. Maybe there is some &quot;earlier&quot; time than the launch activity's onCreate() and a better place to store the values than a custom static (or singleton) class?</p>