java - How to call a private method of a class in different package -


there bookview.class has private method defined below

  public class bookview{     private boolean importbook(string epubbookpath){     //the function adds books database.     }   } 

i trying call function different package. code is

    protected void onpostexecute(string file_url) {         // dismiss dialog after file downloaded         dismissdialog(progress_bar_type);          /*now add book information sqlite file.*/         textview textview=(textview)findviewbyid(r.id.textview1);         string filename = textview.gettext().tostring();         string basedir = environment.getexternalstoragedirectory().getabsolutepath();         string epubbookpath = basedir+filename;         log.i("epubbookpath:",epubbookpath); //no errors till here!          try {             method m=bookview.class.getdeclaredmethod("importbook");             m.setaccessible(true);//abracadabra              //i need here! how pass epubbookpath private importbook method.         } catch (nosuchmethodexception e) {              e.printstacktrace();         }         intent in = new intent(getapplicationcontext(),                 callepubuiactivity.class);                 startactivity(in);     } 

edit:

i found public method in jar file doing above work.

  public void jsimportbook(string epubbookpath) {      if (!bookview.this.importbook(epubbookpath))      return;    bookview.this.createbookshelf();   } 

if want should make public or make public wrapper method it.

if thats not possible, can work way around it, thats ugly , bad , should have really reasons so.

public boolean importbook(string epubbookpath){     //the function adds books database. } 

or

public boolean importbookpublic(string epubbookpath){     return importbook(epubbookpath); } private boolean importbook(string epubbookpath){     //the function adds books database. } 

also note if can't access method directly in third-party library intended way. take @ call hierarchy of private method , see if find public method call private 1 , need.

libraries designed in way public method checking (all parameters given, authenticated etc.) , pass call private method actual work. never want work around process.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -