开发者

Android - referencing string array using another string to avoid using SQLite

I've searched for this but I'm not exactly sure what I should be searching for.

I'm trying to avoid using a SQLite DB and was wondering is it possible to call a string using the value of another string.

Eg.

If I have in a xml file this:

    <string-array name="bob">
<item>1</item>
<item>4</item>
<item>7</item>
<item>11</item>
</string-array>

And in a Java file this:

String name = "bob";

can I then do something like this:

String[] holder = getResources()开发者_开发技巧.getStringArray(R.array.name);

Thanks!


If I guess correctly what you are needing is getIdentifier(). Take into account that this method is expensive and it is much more efficient to retrieve resources by identifier.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜