1

Within my Android application I want to connect to a PHP file on my server/web host. Currently I cannot POST data to the PHP file, I think I am passing the URL in an incorrect format.

Using a Google URL as an example, would this be correct in order to establish the path to my PHP file?

URL url = new URL("http://74.125.224.72/myFile.php");

1 Answer 1

2

It seems that you have an extra space in your URL

URL url = new URL("http://74.125.224.72 /myFile.php");

must be

URL url = new URL("http://74.125.224.72/myFile.php");

EDIT You can also use the android Uri class and build it using the Uri.Builder

Uri uri = new Uri.Builder()
    .scheme("http")
    .authority("74.125.224.72")
    .appendPath("myFile.php")
    .build();
Sign up to request clarification or add additional context in comments.

3 Comments

Sorry, that was a mistake. Doe the URL look ok otherwise?
It seems ok. I edited my answer to show you the use of Uri.Builder.
Thanks, Can I also use the actualy web address? Using Google as an Exmaple: URL url = new URL("mywebsitename/myFile.php");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.