Can I compare the data from getStringExtra() with a string?
Sample code:
Intent intent = getIntent();
String path = intent.getStringExtra("category");
if(path == "car"){
setListAdapter(new ArrayAdapter<String>(this, R.layout.subcategory, car));
} else {
setListAdapter(new ArrayAdapter<String>(this, R.layout.subcategory, bike));
}
Why is the script is not running?
When comparing two strings to check if they are equal in java you should use equals().
In your case you should change your comparison line to
In java the equals() compares the actual contents of your strings while == will only compare to see if the two references are equal