How to get a file path from c drive in android
- by Thomas Mathew
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.