title: How to Get Package Name of Source Class File in Android ?
body: <p>I am using only one project to port lite and full versions for that I am just updating Manifest file package names.</p>
  
  <p>My project structure is like this  </p>
  
  <p>My App <br>
  &thinsp;&thinsp;&thinsp;&thinsp;&thinsp;  |_src <br>
   &thinsp;&thinsp;&thinsp; &thinsp;  &thinsp; &thinsp; |_com.example.myapp <br>
  &thinsp;&thinsp;&thinsp; &thinsp;  &thinsp; &thinsp;  &thinsp; &thinsp; &thinsp; &thinsp; &thinsp; &thinsp; &thinsp; &thinsp; &thinsp; &thinsp; &thinsp; &thinsp; &thinsp; &thinsp; &thinsp; &thinsp; &thinsp; &thinsp;  |_MyClass.java</p>
  
  <p>and my Manifest package name is different.</p>
  
  <p>package="com.example.myapplite"</p>
  
  <p>I am using one library project in that I want package names of classes that I am using in MyApp.</p>
  
  <p>I have used this</p>
  
  <pre><code>        System.out.println("Package Name " + context.getPackageName());
  </code></pre>
  
  <p>But its giving me a Manifest file package name value ie. <em>com.example.myapplite</em> </p>
  
  <p>I want MyClass.java package name. ie. <em>com.example.myapp</em></p>
  
  <p>Also I am aware about this</p>
  
  <pre><code> MyClass mClass = new MyClass();
   Package pack = mClass.getClass().getPackage();
  </code></pre>
  
  <p>But I can't use this approach because I am using following approach to get class file in my library project  </p>
  
  <pre><code>Class c = Class.forName("package_name.MyClass");
  </code></pre>
  
  <p>How to get package name of MyClass.java file programmatically?</p>