开发者

Android in accessing value of a string

开发者 https://www.devze.com 2023-04-08 10:31 出处:网络
I am working on androi开发者_StackOverflow社区d. i want to access the file from server. if i write my url in this way:

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

精彩评论

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