First of all, you need to understand the static variable,
A static variable is one that's associated with a class, not objects of that class. Find out more here : https://www.caveofprogramming.com/java/java-for-beginners-static-variables-what-are-they.html
To resolve your issue is quite simple:
First Step:
Make sure in your mainActivity file to have a static variable:
public static String <string_name>;
Second Step:
Make sure in your secondActivity file to put static between import and the path of the mainActivity file.
import static com.<path of your mainActivity>;
And you can access your variable easily in your entire secondActivity
I'm newbie here, please correct me if I'm giving wrong answer
Thanks 😁
Activityis just a normal Java class so may be able to access its variables directly if they are public, or using a getter method if they are private.static