Getting string resource by name
<p>I have seen several threads about this question but I don't know why they are not working for me. Here the short code:</p>

<pre><code>//This doesn't work. I'm getting a 0 id
id=getResources().getIdentifier("q1", "id", getPackageName());

//This retrieves the string correctly (just to prove the string is called q1
String str=getResources().getString(R.string.q1);
</code></pre>

<p>The only thing I could think about is a problem with the packagename, but it seems Ok.</p>

<p>Any help?</p>
