使用 iText,如何提供从设备或模拟器存储 PDF 文件的路径?

Using iText, how to give Path to store PDF file from Device or Emulator?

我正在开发发票应用程序,所以我正在使用 iText 创建 PDF 文件,例如发票。我想将 PDF 文件存储在 SD 卡或计算机本身中。但它不起作用,因为应用程序无法访问路径。

但是当我在 Java 应用程序中尝试相同的代码时,会创建文件 sucessfully.Path 在计算机 LocalDisk 中给出。

我要给出要存储的文件路径,

  1. 在真实设备的SD卡中。
  2. 在计算机本地磁盘中(以防 App 在模拟器上运行)。

怎么办?感谢您的帮助。

In the SD Card of real Device.

如果 "the SD Card",您的意思是 Android SDK 指的是 external storage, you have a number of options for getting a path to a spot to write your file. Off the cuff, I would recommend getExternalStoragePublicDirectory() on the Environment class

如果"the SD Card",你的意思是removable storage,在Android 4.4之前的Android SDK不支持。

In the Computer LocalDisk (in case App works on Emulater).

不支持。仿真器无法写入开发 PC 的文件系统。不过,emalator 可以有自己的模拟外部存储。