Pushpendra Kuntal
Pushpendra Kuntal

Reputation: 6186

Android in accessing value of a string

I am working on android. 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.

Upvotes: 0

Views: 186

Answers (1)

Niranj Patel
Niranj Patel

Reputation: 33248

try this

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

Upvotes: 5

Related Questions