Q: Getting SubString from String in Java(Android) I have a String name packageName="https://play.google.com/store/apps/details?id=com.MoversGames.DinosaurWorldGame"; 
How i can get subString from this string. I want to take "id=com.MoversGames.DinosaurWorldGame" this from String packgeName. The length of this String may change. It is not constant its variable . 

A: You need to use String.substring()
Try to substring your string from the index of id to length of your string
In this below example i have started substring from index of ? +1 so it will start substring your string from id  to length of your string
SAMPLE CODE
    String packageName = "https://play.google.com/store/apps/details?id=com.MoversGames.DinosaurWorldGame";

    String answer = packageName.substring(packageName.indexOf("?")+1, packageName.length() );
    Log.e("ANSWER", answer);

OUTPUT
2018-10-11neel.com.myapplication E/ANSWER: id=com.MoversGames.DinosaurWorldGame


A: There might be also some more query parameters in your String , so you can also try it like this :
String packageName = "https://play.google.com/store/apps/details?i 
id=com.MoversGames.DinosaurWorldGame&x=y&z=a";

String answer = packageName.substring(packageName.indexOf("id"));
System.out.print("ANSWER", answer);

