【问题标题】:Accessing APK files from unrooted Android device [closed]从无根的 Android 设备访问 APK 文件 [关闭]
【发布时间】:2013-10-14 12:17:20
【问题描述】:

我们如何从无根设备访问 APK 文件并将其复制到外部存储?

任何指导都会很棒,

谢谢

【问题讨论】:

    标签: android eclipse performance storage apk


    【解决方案1】:

    使用此功能将 APK 从源包路径复制到您的 sdcard(无需 root 访问权限)

    public static boolean copyFile(String srcFilePath, String destFilePath)
         {
         boolean success = false;
    
         if(srcFilePath!=null && destFilePath!=null)
         {
         srcFilePath = srcFilePath.trim();
         destFilePath = destFilePath.trim();
    
         if(!srcFilePath.equals("") && !destFilePath.equals("") && !srcFilePath.equals(destFilePath))
         {
         File srcFile = new File(srcFilePath);
    
         if(srcFile.exists() && srcFile.isFile())
         {
         try
         {
         File destFile = new File(destFilePath);
         InputStream in = new FileInputStream(srcFile);
         OutputStream out = new FileOutputStream(destFile);
    
        // Transfer bytes from in to out
         byte[] buf = new byte[1024];
         int len;
         while ((len = in.read(buf)) > 0)
         {
         out.write(buf, 0, len);
         }
    
         in.close();
         out.close();
         success = true;
         }
         catch (Exception e)
         {
         e.printStackTrace();
         }
         }
         }
         }
         return success;
         }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-22
      • 1970-01-01
      • 2014-03-07
      相关资源
      最近更新 更多