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");
精彩评论