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.
please 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 (eg, 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.