Create a bean
package com.storageproj;
public class myStorage{
private String Name;
private String Count;
private String Amount;
public String getName() {
return Name;
}
public void setName(String Name) {
this.Name= Name;
}
public String getCount() {
return Count;
}
public void setCount(String Count) {
this.Count= Count;
}
public String getAmount() {
return Amount;
}
public void setAmount(String Amount) {
this.Amount= Amount;
}
}
Import your bean to your main class
import com.storageproj.myStorage;
Then set your data, for example
int Numberofelements = 10;
myStorage = new myStorage[Numberofelements];
for(int i=0;i<Numberofelements;i++){
myStorage [i] = new myStorage ();
myStorage.setName("carrot");
myStorage.setCount("3");
myStorage.setAmount("4");
}
and get the values...
import com.storageproj.myStorage;
myStorage[] myStorage;
for the first element...
if (myStorage[0].getName == "carrot"){
Toast.makeText(this, "Carrot, Count= " + myStorage[0].getCount() + ", Amount="+ myStorage[0].getAmount() ,Toast.LENGTH_LONG).show();
}