开发者

Android in accessing value of a string

I am working on androi开发者_StackOverflow社区d. i want to access the file from server. if i write my url in this way:

URL sourceUrl = new URL("http://192.168.1.214/MusicApplication/searchsongxml.php?");

then it works correctly.

But if i declare the server name in strings.xml as follows:

<resources>  
    <string name="SERVER_NAME">http://192.168.1.214/</string>
</resources>

and try to access the url like this:

URL sourceUrl = new (getString(R.string.SERVER_NAME)+"MusicApplication/searchsongxml.php");

then this create an exception and my application halts.

Please tell me what mistake i have done.


try this

URL sourceUrl = new URL(your_context.getString(R.string.SERVER_NAME)+"MusicApplication/searchsongxml.php");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜