3

I my application I should parse URl and I should get id number from Id

http://example.com/cat/detail/proc?id=147&_prof=W6IYDQZ2F2YOVBC78RUA

How can I parse this url and get id and prof ?

3 Answers 3

11

Use getQueryParameter()

 Uri uri=Uri.parse("http://example.com/cat/detail/proc?id=147&_prof=W6IYDQZ2F2YOVBC78RUA");
String id = uri.getQueryParameter("id");
String _prof = uri.getQueryParameter("_prof");
Sign up to request clarification or add additional context in comments.

Comments

0
Uri uri = Uri.parse("http://example.com/cat/detail/proc?id=147&_prof=W6IYDQZ2F2YOVBC78RUA");
String id = uri.getQueryParameter("id");

Comments

0

Try this

List<NameValuePair> parse = URLEncodedUtils.parse(URI.create("http://example.com/cat/detail/proc?id=147&_prof=W6IYDQZ2F2YOVBC78RUA"), "UTF-8");
        for (NameValuePair pair : parse) {
            System.out.println("!!!!!!!!!! " + pair.getName() + " = " + pair.getValue());
    }

Comments

Your Answer

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