Is there any way to open .doc file in Android?
I have created a app that displays all the content from res/raw folder.
I need that when i click on .doc file it should open and I can view its content.
plea开发者_如何学运维se help me.
I have ThinkFree.
enter code here
public class FileList extends ListActivity {
public static final Field[] fields = R.raw.class.getFields();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<Field>(this, R.layout.row, R.id.weekofday, fields));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
//super.onListItemClick(l, v, position, id);
String selection = l.getItemAtPosition(position).toString();
Toast.makeText(this, selection, Toast.LENGTH_SHORT).show();
Intent i = new Intent();
i.setAction(android.content.Intent.ACTION_VIEW);
startActivity(i);
}
}
What you want is not possible. A third-party application will not be able to read a Word document out of your raw resources.
At best, you could copy the file from the raw resource someplace (e.g., external storage), then call startActivity()
on an ACTION_VIEW
Intent
that has a Uri
pointing to the readable copy and also has the proper MIME type.
Of course, this will only work on a device that has a Word document viewer on it.
精彩评论