如何在Android应用程序中将检索到的值保存到pdf文件中

时间:2013-12-04 06:29:22

标签: android

我在应用程序中检索了一些值,我可以在ListViewTextView中查看。但是相同的值可以存储或查看PDF,Word,Excel中的任何可能性 如果有请解释。

1 个答案:

答案 0 :(得分:0)

希望这可以帮助...

public void appendLog(String text)
{       
   File logFile = new File("sdcard/log.txt");
   if (!logFile.exists())
   {
      try
      {
         logFile.createNewFile();
      } 
      catch (IOException e)
      {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
   }
   try
   {
      //BufferedWriter for performance, true to set append to file flag
      BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true)); 
      buf.append(text);
      buf.newLine();
      buf.close();
   }
   catch (IOException e)
   {
      // TODO Auto-generated catch block
      e.printStackTrace();
   }
}

不要忘记在Manifest中添加writing_external_storage的权限!