6

I read the Android documentation for USB support at http://developer.android.com/guide/topics/connectivity/usb/host.html and come to know that

Android support the USB host mode, we can read any file from the usb device.

In my case I have a pdf file which is stored in USB pen drive I want to attach the pen drive to my android device and want to read the pdf file data using the phone. Please help me to solve this any demo project or tutorial link to cover this topic. Thanks

4

1 回答 1

-1
  String extStorageDirectory  = context.getExternalCacheDir().getAbsolutePath();

在这里,它获得的路径为:/mnt/sdcard/Android/data/com.example/cache

现在用这个路径附加你的文件名。例如abc.txt

/mnt/sdcard/Android/data/com.iris.activity/cache/abc.txt

现在使用 File 类并从此路径获取 InputStream 并从 InputStream 读取文件。

于 2012-10-31T12:19:58.697 回答