I want to be able to access a word file in the sdcard of the user\'s phone, and the file will be chosen by the user. I want to be able to process the file, i.e. read its con
Your question needs some more clarification
Anyway this is what you should do to edit the file
Read the file
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard,"theFILE");
StringBuilder content = new StringBuilder();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
content.append(line);
content.append('\n');
}
}
catch (IOException e) {
}
Edit the content
content.append("bla bla");
content.append("kaza maza");
Save the file
FileOutputStream f = new FileOutputStream(file);
f.write(content.toString().toCharArray());
Remember to add to your manifest the permissions to write to the sdcard:
Validation
Unfortunately this is the hardest part. Apache POI is a choice; however it is a large library that does not guarantee the right behavior.
The perfect solution is to check the MS-DOC format. It is a really big requirement. For such a limited application, I guess you won't find anything if you search the web. Therefore, you will have to implement a reader that abides by this format.