【问题标题】:Delphi deployment and Android file storageDelphi部署和Android文件存储
【发布时间】:2014-12-22 21:51:10
【问题描述】:

如果我尝试将文件部署到部署 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
  ;

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

【问题讨论】:

    标签: android delphi delphi-xe7


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢 - 它现在似乎工作了。不太确定如何创建一系列没有产生解决方案的测试:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多