Delphi部署和Android文件存储

时间:2014-12-22 21:51:11

标签: android delphi delphi-xe7

如果我尝试将文件部署到部署 assets \ internal \ assets.zip assets.zip ,请执行以下操作: enter image description here

我尝试了各种路径,看看是否可以找到assets文件夹或我的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
  ;

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

1 个答案:

答案 0 :(得分:3)

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

S4 := TPath.Combine(TPath.GetDocumentsPath, 'assets.zip');
if (FileExists(S4)) then