开发者

Converting R.java variable to URI

Is this possible converting R.java variable to URI reference? What can be URI?

开发者_运维百科

PS: So silly question I know. But thanks for your kind helps..


Do you mean that you're storing URIs as string values in an xml file, and need to convert those into java.net.URI objects?

If so...

In an xml file called uris.xml

<resources>
    <string name="stackoverflow">http://www.stackoverflow.com</string>
</resources>

And then in your Java code you can use

import java.net.URI;

URI stackoverflowUri = new URI(getResources().getString(R.uri.stackoverflow));

(you'll need to add code to catch any URISyntaxException thrown by the new URI call)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜