Validating and reading a Word file in Android

android, ms-word

Solution

Simplest way IMHO is to port Apache POI library to Android. It's possible and there proof of that

Porting POI you can embed Word editing feature into your application.

Piece of code like:

Intent intent = new Intent(Intent.ACTION_EDIT); 
Uri uri = Uri.parse("file:///"+file.getAbsolutePath()); 
intent.setDataAndType(uri, "plain/text"); 
startActivity(intent);

Simply means that Word file will be edited by some other application - not yours. As far as I understand it's not exactly what you want.

Problem

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 contents and modify it as the user wishes, and save it when the user clicks “save.” Is it possible in Android? How can I make the program understand that the file is a Word file? Note that I don't want to view the Word file. The user will select the Word file and my app should be able to make some changes to it and save it.

Original source

Related problems