Reputation: 1617
How do you replace strings when you retrieve a data from an activity ? I cant seems to find it google. Maybe my question is too simple. Please see the below codes.
Intent in = getIntent();
textToPass = in.getStringExtra("textToPass");
textToPass is actually a string eg. "ExampleText.txt"
How do you remove the .txt to make it look like "ExampleText"
I might be somewhere near, but I still couldnt figure out
String exampletext = textToPass.getText().toString().replace(".txt","");
Upvotes: 0
Views: 228
Reputation: 2719
Intent in = getIntent();
String textToPass = in.getStringExtra("textToPass");
String[] exampletext = textToPass.split("//.");
Then use exampletext[0] it must give your expectation result
Upvotes: 0
Reputation: 56925
Here textToPass is string so you can directly apply replace method on it .
textToPass.replace(".txt","");
Upvotes: 1