I have the String content://com.android.contact/data/5032 in a variable Str1. I want to manipulate Str1 so that I will get 5032 in another string variable.
Can anyone suggest the answer?
I have the String content://com.android.contact/data/5032 in a variable Str1. I want to manipulate Str1 so that I will get 5032 in another string variable.
Can anyone suggest the answer?
If you want go get digits from the given string try this:
String str = "content://com.android.contact/data/5032";
String str2 = str.replaceAll("\\D+","");
System.out.println(str2);
Output:
5032
If you want to split try this:
String[] string = str.split("//|/");
System.out.println(string[string.length -1 ]);
Output:
5032
Please write names of variables starting with a small letter. You can use the split method to do this. You might find this related question interesting: How to split a string in Java.