title: Fragment Getting Method from Another Class
body: <p>I have an Android app that uses fragments. I'm also following a tutorial (<a href="http://android2011dev.blogspot.ie/2011/08/get-android-phone-call-historylog.html" rel="nofollow">CallLogs Tutorial</a>) to get the calls history.</p>
  
  <p>I have the a class made by the tutorial in the link but now I want to get data from this class and use it in one of my fragments. </p>
  
  <p>I've tried something like the following;</p>
  
  <pre><code>    int callsMade = new GetUsage().getCallDetails();
      String callsmade = String.valueOf(callsMade);
  
      Log.e("Calls Made:", "Texts: " + callsmade);
  </code></pre>
  
  <p>But I keep getting an error on the "Cursor managedCursor" line (NB: I've changed the managedCursor to getContentResolver since managedCursor is deprecated and get the error too)</p>
  
  <p>Is there something I'm doing wrong here? Anthing ye can think of that I can change?</p>
  
  <p>Thanks alot for any help you can provide.</p>
  
  <p>EDIT:
  Code for getCallDetails();</p>
  
  <pre><code>public int getCallDetails() 
  {
  
      StringBuffer sb = new StringBuffer();
      Cursor callsCursor = getContentResolver().query( CallLog.Calls.CONTENT_URI,null, null,null, CallLog.Calls.DATE + " DESC");
      //Cursor planCursor=PlansHelper.query("plans", null, null, null, null);
      int name = callsCursor.getColumnIndex( CallLog.Calls.CACHED_NAME );
      int number = callsCursor.getColumnIndex( CallLog.Calls.NUMBER ); 
      int type = callsCursor.getColumnIndex( CallLog.Calls.TYPE );
      int date = callsCursor.getColumnIndex( CallLog.Calls.DATE);
      int duration = callsCursor.getColumnIndex( CallLog.Calls.DURATION);
      int allduration = 0;
  
  
      sb.append( "Call Details :");
      while ( callsCursor.moveToNext() ) 
      {
  
          String phName = callsCursor.getString( name );
          String phNumber = callsCursor.getString( number );
  
          String callType = callsCursor.getString( type );
          int callTypeCode = Integer.parseInt(callType);
  
          String callDate = callsCursor.getString( date );
          Date formatDate = new Date(Long.valueOf(callDate));
          SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
          String dateStr = sdf.format(formatDate);
  
          String userdate = "18/03/2014";
  
          //Date parseddate = sdf.parse(userdate1);
  
          Calendar c = Calendar.getInstance();
          try {
              c.setTime(sdf.parse(userdate));
          } catch (ParseException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          c.add(Calendar.DATE, -5);  // number of days to add
          userdate = sdf.format(c.getTime());  // dt is now the new date
  
  
          String callDuration = callsCursor.getString(duration);
          float durationToFloat =Float.parseFloat(callDuration);
          float durationToMins = durationToFloat/60;
          int durationRounded = Math.round(durationToMins);
          int callDurationMin = durationRounded;
  
  
          if(callTypeCode==CallLog.Calls.OUTGOING_TYPE)
          {
  
              //if(dateStr.equals(userdate) || dateStr.equals(userdate1))
              if(formatDate.after(c.getTime()))
              {
                  sb.append("\nName:--- " + phName + "\nPhone Number:--- " + phNumber + " \nCall Date:--- " + dateStr
                          + " \nCall duration in min :--- " + callDurationMin);
                  sb.append("\n----------------------------------");
                  allduration = allduration + callDurationMin;
                  Log.d(getClass().getSimpleName(), "Done");
              }
          }
  
  
      }
  
      sb.append("##" + allduration + "##");
      getCalls.setText(sb.toString());
      callsCursor.close();
  
      return allduration;
  
  }
  </code></pre>