How to get a file path from c drive in android

Posted by Thomas Mathew on Stack Overflow See other posts from Stack Overflow or by Thomas Mathew
Published on 2011-01-03T01:46:21Z Indexed on 2011/01/03 1:53 UTC
Read the original article Hit count: 530

Filed under:

I was trying to extract the content of a pdf file and display its content in android. I tired the code in java and it worked.But when i am coding it in android, its not displaying anything. I think, its not getting the file path. Is there any way by which i could get a file stored in c drive and store its path in a string? The code is given below:

public class hello extends Activity {
      /** Called when the activity is first created. */
        private static String INPUTFILE = "FirstPdf.pdf";
        String str;


      @Override

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {
    Document document = new Document();


    document.open();
    PdfReader reader = new PdfReader(INPUTFILE);

    int n = reader.getNumberOfPages();
       str=PdfTextExtractor.getTextFromPage(reader, 2);

    } catch (IOException e) {

        //e.printStackTrace();
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    TextView tv = new TextView(this);
    tv.setText(str);
    setContentView(tv);
   }
}

I would be very grateful if the problem is solved.

© Stack Overflow or respective owner

Related posts about android