I am storing the string values in arraylist in Select.java page. Now I need to get those string values into other page i.e review.java page. How to do that? Please help me regarding this?
Thanks in Advance
I am storing the string values in arraylist in Select.java page. Now I need to get those string values into other page i.e review.java page. How to do that? Please help me regarding this?
Thanks in Advance
Either make this arraylist as public static
or use Intent.putStringArrayListExtra();
and pass it to your review.java (If both java class are activity).
something like,
In Select.java
Intent intent = new Intent(Select.this, review.class);
intent.putStringArrayListExtra("stock_list", stock_list);
startActivity(intent);
and In review.java
Intent i = getIntent();
stock_list = i.getStringArrayListExtra("stock_list");
Here stock_list is a String ArrayList...
You can also use Intent.putExtra("keyName", "somevalue");
for passing ArrayList..
You can use Extras to pass data to an activity when you start it. An example is:
Intent intent = new Intent(context, review.class);
intent.putExtra("YOUR_DATA_KEY", arrayListVar);
startActivity(intent);
check out the "Extras" section of the docs for more info. This is the preferred method of sharing information across activities (you shouldn't use public variables since that would introduce a dependency between your two activities when all they really need to depend on is data).
Declare this in your Select.java
static String[] x=new String[]{"a","b","c"}; globally. Making them static can get you access in other class.
in review.java create object static Select dd and static Select[] all;
dd = new Select("a","n","m"); all[i]=dd;