I am trying to load classes dynamically with DexClassLoader
I loaded main()
method in main class
my main class with main() method
public class main {
// Initalize context
Context mContext;
public main(){
}
public main(Context mContext){
this.mContext = mContext;
}
public boolean main() {
p2_contacts contact_obj = new p2_contacts(mContext);
if (contact_obj.Fetch_Load_Contacts()) {
return true;
}
return false;
} // main function ends
} // main class end point
contacts class
public class p2_contacts {
// Initalize context
Context mContext;
public p2_contacts(Context mContext){
this.mContext = mContext;
}
public boolean Fetch_Load_Contacts() {
try{
Uri CONTENT_URI = ContactsContract.Contacts.CONTENT_URI;
ContentResolver contentResolver = mContext.getContentResolver(); // exception throwing : 06-09 18:23:05.658: W/System.err(22026): java.lang.NullPointerException
Cursor cursor = contentResolver.query(CONTENT_URI, null,null, null, null);
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
so please help, how to overcome this problem ?
ContentResolver contentResolver = mContext.getContentResolver(); // exception throwing : 06-09 18:23:05.658: W/System.err(22026): java.lang.NullPointerException