Java include snippet in different class files?
<p>I wrote a listener that does some actions onKeyDown basically I need to include it in all my activities but I'm new to Java and don't know the best way to do it, I can of course just copy paste the code on every class but it would be a pain to keep every one updated.</p>

<pre><code>@Override
public boolean onKeyDown(int keyCode, KeyEvent event)  {
    if(sharedPrefs.getBoolean("pref_disable_keydowns", true)) {
        System.out.println("Prevent keydown");
        return true; 
        }
    return super.onKeyDown(keyCode, event);
}
</code></pre>

<p>How can I include this in different .java files so I only have to modify it once to affect all classes it's included?</p>
