Delphi部署和Android文件存储

Tom*_*Tom 1 delphi android delphi-xe7

如果我尝试将文件部署到部署assets\internal\assets.zipassets.zip,如下所示: 在此处输入图片说明

我尝试了各种路径来查看是否可以找到资产文件夹或我的 zip 文件。所有底层代码都不成功

  S1 := TPath.GetHomePath + PathDelim;
  S2 := FAppDataDirPathRoot + Application.Title + '.app' + PathDelim;
  S3 := TPath.GetLibraryPath + PathDelim;
  S4 := TPath.GetDocumentsPath + PathDelim;

  if (DirectoryExists(S1)) then // '/data/data/com.embarcadero.xxx/files/': yes:
    msAppNoOp
  ;
  if (DirectoryExists(S2)) then // ...: no, leftover test from iOS
    msAppNoOp
  ;
  if (DirectoryExists(S3)) then // '/data/app-lib/com.embarcadero.xxx-2/': yes
    msAppNoOp
  ;
  if (DirectoryExists(S4)) then // '/data/data/com.embarcadero.xxx/files/' yes
    msAppNoOp
  ;

  if (DirectoryExists(S1 + 'assets' + PathDelim)) then // no
    msAppNoOp
  ;
  if (DirectoryExists(S2 + 'assets' + PathDelim)) then // no
    msAppNoOp
  ;
  if (DirectoryExists(S3 + 'assets' + PathDelim)) then // no
    msAppNoOp
  ;
  if (DirectoryExists(S4 + 'assets' + PathDelim)) then // no
    msAppNoOp
  ;

  S1 := S1 + 'assets.zip';
  S2 := S2 + 'assets.zip';
  S3 := S3 + 'assets.zip';
  S4 := S4 + 'assets.zip';


  if (FileExists(S1)) then // no
    msAppNoOp
  ;
  if (FileExists(S2)) then // no
    msAppNoOp
  ;
  if (FileExists(S3)) then // no
    msAppNoOp
  ;
  if (FileExists(S4)) then // no
    msAppNoOp
  ;
Run Code Online (Sandbox Code Playgroud)

在 Windows 资源管理器中浏览我的手机时,我看不到数据/数据/...我认为这只能是有 root 权限的手机...

Rem*_*eau 5

根据文档,如果您部署到assets/internal那么您需要使用TPath.GetDocumentsPath来获取运行时所部署文件所在的文件夹。尝试使用TPath.Combine()而不是PathDelim直接使用:

S4 := TPath.Combine(TPath.GetDocumentsPath, 'assets.zip');
if (FileExists(S4)) then
Run Code Online (Sandbox Code Playgroud)