Methods have access modifiers too

It makes sense because methods are the things that our classes can do. We will want to control what users of our class can and can't do.

The general idea here is that some methods will do things internally only and are, therefore, not needed by users of the class and some methods will be fundamental to how users of the class, well, use your class.

The access modifiers for methods are the same as for the class variables. This makes things easier to remember but suggests, again, that successful encapsulation is a matter of design rather than of following any specific set of rules.

As an example, this next method, provided it is in a public class, could be used by any other class that has instantiated an object of the appropriate type.

public useMeEverybody(){
   // do something everyone needs to do here
}

Whereas this method could only be used internally by the class that contains it.

private secretInternalTask(){
   /*
      do something that helps the class function internally
      Perhaps, if it is part of the same class,
      useMeEverybody could use this method-
      On behalf of the classes outside of this class.
      Neat!
   */
}

And this next method with no access specified has default visibility. It can be used only by other classes in the same package. If we extend the class containing this default access method it will not have access to this method.

fairlySecretTask(){
   // allow just the classes in the package
   // Not for external use
}

As the last example before we move on, here is a protected method, only visible to the package, but usable by our classes that extend it, just like onCreate.

protected packageTask(){
   // Allow just the classes in the package
   // And you can use me, if you extend me, too
}

Method access summary

Method access should be chosen to best enforce the principles we have already discussed. It should provide the users of your class with just the access they need and preferably nothing more. Thereby we achieve our encapsulation goals, like keeping the internal workings of your code safe from interference from the programs that use it, for all the reasons we have discussed.