title: Android Beginner // Why are my Variables all 0 after i should have filled them?
body: <p>I just edited this post from my original one, because i could narrow the Problem down, but didn´t want to open an extra post for it.</p>
  
  <p><strong>What i Want</strong>
  I have an Activity in which i generate Data from Houses into an Array. Then on opening another Activity the Data should be used for displaying it.</p>
  
  <p><strong>My Problem</strong>
  The Data gets generated correctly, and I can see in my Logs that it is generated before i want to access it. At access it still doesn´t show me my Data. </p>
  
  <p><strong>My Code</strong></p>
  
  <p>Houses.java (Where i generate the Houses and use the Answer already given below to try to get my Data)</p>
  
  <pre><code>public class Houses{
  
  int[][] NewHouseProps = new int[20][10];
  int[][] HouseProps;
  
  public Houses(){
  }
  
  public ArrayList&lt;Integer&gt; getClasses()
  {
      ArrayList&lt;Integer&gt; classes = new ArrayList&lt;&gt;();
      Log.d("Test","ID: "+3+" CLASS: "+NewHouseProps[3][0]);
      Log.d("Test","ID: "+4+" CLASS: "+NewHouseProps[4][0]);
      for(int id=0 ; id&lt;=8; id++) {
          classes.add(NewHouseProps[id][0]);
          Log.d("getClasses","Classes: "+NewHouseProps[id][0]);
          Log.d("getClasses!!!!!!!!!", "List: "+classes.get(id));
      }
  
      return classes;
  }
  
  public void GenerateHouses(){
      Log.d("Generate Houses","!!");
      for(int id=0; id&lt;=8; id++){
              Random r = new Random();
              int h_class, garage = 0, rooms = 0, furn = 0, balkon = 0, pool = 0;
              h_class = r.nextInt(4); //Klasse
              if(h_class == 0){
                  rooms = r.nextInt(4)+1;
                  balkon = r.nextInt(1);
              }else if(h_class == 1){
                  rooms = r.nextInt(3)+3;
                  garage = r.nextInt(1)+1;
                  pool = r.nextInt(1);
                  balkon = r.nextInt(2);
              }else if(h_class == 2){
                  rooms = r.nextInt(3)+2;
                  garage = r.nextInt(2)+2;
                  pool = r.nextInt(1);
              }else if(h_class == 3){
                  rooms = r.nextInt(8)+6;
                  garage = r.nextInt(6)+4;
                  pool = r.nextInt(1);
                  balkon = r.nextInt(3);
              }
              furn = r.nextInt(1);
  
              int price = GenerateHousePrice(id, h_class, garage, rooms, furn, balkon, pool);
              NewHouseProps[id][0] = h_class;
              NewHouseProps[id][1] = price;
              NewHouseProps[id][2] = rooms;
              NewHouseProps[id][3] = furn;
              NewHouseProps[id][4] = balkon;
              NewHouseProps[id][5] = pool;
              NewHouseProps[id][6] = garage;
              Log.d("ID: ", Integer.toString(id));
              Log.d("CLASS: ",Integer.toString(NewHouseProps[id][0]));
              Log.d("PRICE: ", Integer.toString(NewHouseProps[id][1]));
      }
  
  }
  
  public int GenerateHousePrice(int id, int h_class, int garage, int rooms, int furn, int balkon, int pool){
  
      int price = 0, pricep = 0;
      Random r = new Random();
      if(h_class == 0){
          price = r.nextInt(150000)+50000; // 50 - 200 tausend
          price += rooms * 7500;
      }
      else if(h_class == 1){
          price = r.nextInt(165000)+85000; //85 - 250 tausend
          price += rooms * 12500;
      }
      else if(h_class == 2){
          price = r.nextInt(300000)+100000; //100 - 400 tausnd
          price += rooms * 20000;
      }
      else if(h_class == 3){
          price = r.nextInt(800000)+500000; // 500 - 1.3 Mill.
          price += rooms * 15000;
      }
  
      if(garage &gt; 0){
          pricep += price*0.20;
          pricep += garage * 500;
      }
      if(furn == 1){
          pricep += price*0.25;
      }
      if(balkon &gt; 0){
          pricep += price*0.1;
          pricep += balkon*500;
      }
      if(pool == 1){
          pricep += 20000;
      }
      price += pricep;
      return price;
  }
  </code></pre>
  
  <p>BuyHousesActivity.java(Here the Data should be accessed and displayed)</p>
  
  <pre><code>public class BuyHousesActivity extends FragmentActivity {
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_buy_houses);
      Houses h = new Houses();
      ArrayList&lt;Integer&gt; classes = h.getClasses();
      for(int id=0;id&lt;=8;id++){
          Log.d("OnCreate Classes: ","Classes: "+classes.get(id));
      }
      List&lt;Integer&gt; images = new ArrayList&lt;&gt;();
      images.add(R.drawable.apartment);
      images.add(R.drawable.townhouse);
      images.add(R.drawable.bungalow);
      images.add(R.drawable.villa);
      ViewPager viewPager = findViewById(R.id.vpPager);
      viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), images));
  
  }
  
  
  
  protected class MyViewPagerAdapter extends FragmentStatePagerAdapter {
      private List&lt;Integer&gt; imageList;
  
      MyViewPagerAdapter(FragmentManager fm, List&lt;Integer&gt; images) {
          super(fm);
  
          imageList = images;
      }
  
      @Override
      public int getCount() {
          return imageList.size();
      }
  
      @Override
      public Fragment getItem(int position) {
          return FragmentBuyHouse.newInstance(imageList.get(position));
      }
  }
  </code></pre>
  
  <p><strong>My Logs</strong>
  Those are the Results of my Logs, with them in place like u see above:
  <a href="https://i.stack.imgur.com/6p6aL.png" rel="nofollow noreferrer">Generating</a>
  <a href="https://i.stack.imgur.com/Fv5sZ.png" rel="nofollow noreferrer">Accessing</a></p>
  
  <p>I hope you can help me and show me what i got wrong and/or forgot.</p>