사운드, 이미지, 텍스트 파일을 최초배포하고, 변경된 파일을 다시 배포할 경우 덮어쓰기(overwrite)가 되지않습니다.(10 시애틀. 2016년 3월) 해당 현상은 안드로이드와 iOS 모두 해당됩니다.

이유는 배포 대상파일이 존재하는 경우(FileExist) 배포를 진행하지 않도록 구현(System.StartUpCopy.pas에 구현)되어 있기 때문입니다.

 

해결 방법은 3가지 정도로 생각해볼 수 있습니다.

1, System.StartUpCopy.pas를 수정하는 방법

2, 업데이트할 파일을 새로운 이름으로 배포하고, 앱 시작시 기존 파일로 덮어쓰는 방법

3, 파일을 앱과 함께 최초 배포 후, 파일 변경이 필요할 경우 인터넷 등을 통해 자동 업데이트 하는 방법

 

1, System.StartUpCopy.pas를 수정하는 방법

http://qc.embarcadero.com/wc/qcmain.aspx?d=125481 링크를 방문해 Xavier Dufaure de Citres 글을 참고해 수정할 수 있습니다.

Xavier Dufaure de Citres at 12/14/2014 3:10:58 PM -
Here is a workaround on Android:
* modify System.StartUpCopy
   - in the interface section add "Var ASSET_OVERWRITE : Boolean = false;"
   - in the interface section exopose "procedure CopyStartUpFiles;"
   - in the CopyAssetToFile change "if (not FileExists(DestFileName)) then" by "if (not FileExists(DestFileName)) or ASSET_OVERWRITE then"

* in your own code, store in the preference file the last version the user ran. If the current version is newer do
  if optLastVersionRan<Version then
  Begin
    ASSET_OVERWRITE := true;
    CopyStartUpFiles;
    ASSET_OVERWRITE := false;
  End;

On the 1st installation the data will be copied twice (no biggy), on update the file will be overwritten.

Note for iOS: i find out that deploying the files i need in ".\Data\" is much better: it put the file directly in the bundle, this way the file are not archived (i got my app rejected because i had 12 Mb of data that was archived). Of course these files can only be read only.

 

2, 업데이트할 파일을 새로운 이름으로 배포하고, 앱 시작시 기존 파일로 덮어쓰는 방법 

배포파일이 업데이트 되면 새로운 파일명으로 배포 후 앱 시작 시 원래파일로 덮어쓰는 방식입니다.

위 이미지와 같이, "deploy.txt" 파일 배포 시 remote name을 "deploy_2.txt"로 배포했습니다.

 

프로젝트에는 아래와 같은 코드를 구현했습니다.(코드에 대한 설명은 생략합니다.)

uses
  System.IOUtils;

procedure TForm1.Button1Click(Sender: TObject);
var
  Path: string;
begin
  Path := TPath.Combine(TPath.GetDocumentsPath, 'deploy.txt');
  Memo1.Lines.LoadFromFile(Path);
end;

procedure TForm1.DeployFileUpdate(const AFilename, AUpdateFilename: string);
var
  OrgPath, UptPath: string;
begin
  OrgPath := TPath.Combine(TPath.GetDocumentsPath, AFilename);
  UptPath := TPath.Combine(TPath.GetDocumentsPath, AUpdateFilename);

  if TFile.Exists(UptPath) then
  begin
    if TFile.Exists(OrgPath) then
      TFIle.Delete(OrgPath);
    TFile.Move(UptPath, OrgPath);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  DeployFileUpdate('deploy.txt',  'deploy_2.txt');
//  DeployFileUpdate('sound1.wav',  'sound1_2.wav');
//  DeployFileUpdate('env.ini',     'env_2.ini');
end;

 

3, 파일을 앱과 함께 최초 배포 후, 파일 변경이 필요할 경우 인터넷 등을 통해 자동 업데이트 하는 방법

배포파일 자동 업데이트는 파일별 버전관리가 필요하며, 업데이트 파일을 내려주는 서버가 필요합니다.

앱 실행 시 배포파일 버전을  서버에서 확인 후 업데이트할 파일이 있으면, Http, FTP 등으로 파일을 다운로드해 배포파일을 교채하는 방식입니다.

웹상의 파일을 다운로드 받는 방법은 아래 링크를 참고할 수 있습니다.

번호 제목 글쓴이 날짜 조회 수
공지 [DelphiCon 요약] 코드사이트 로깅 실전 활용 기법 (Real-world CodeSite Logging Techniques) 관리자 2021.01.19 15512
공지 [UX Summit 요약] 오른쪽 클릭은 옳다 (Right Click is Right) 관리자 2020.11.16 13977
공지 [10.4 시드니] What's NEW! 신기능 자세히 보기 관리자 2020.05.27 16515
공지 RAD스튜디오(델파이,C++빌더) - 고객 사례 목록 관리자 2018.10.23 22079
공지 [데브기어 컨설팅] 모바일 앱 & 업그레이드 마이그레이션 [1] 관리자 2017.02.06 23302
공지 [전체 목록] 이 달의 기술자료 & 기술레터 관리자 2017.02.06 18944
공지 RAD스튜디오(델파이, C++빌더) - 시작하기 [1] 관리자 2015.06.30 39290
공지 RAD스튜디오(델파이,C++빌더) - 모바일 앱 개발 사례 (2020년 11월 업데이트 됨) 험프리 2014.01.16 174742
554 [발표자료] 20160830 나만의 C++애플리케이션 완성하기 with C++빌더 험프리 2016.08.26 1920
553 [FireDAC Skill Sprints] 9. LocalSQL: DB에서 가져온 데이터(데이터셋)를 대상으로 다시 SQL쿼리 실행하기 Humphery 2015.04.01 1912
552 [10.3 리오] IDE가 현대적이고 깔끔하게 업데이트 되었습니다. 관리자 2018.11.14 1887
551 멀티-플랫폼 앱 멋지게! 쉽게! 빠르게! 완성하기 - #.1 한번에 멋지게 개발하기 file 험프리 2019.07.09 1886
550 [개발환경 설정] 안드로이드 기기 연결 시 'USB 디버깅 허용' 창이 표시되지 않는 경우 조치 방법 file 험프리 2018.08.21 1877
549 [동영상] 8단계로 완성하는 "2014년 출시 앨범" 앱 개발 "15"분 만에 완료하기 관리자 2014.10.14 1850
548 [마이그레이션][팁] 유니코드 검토 대상 분석 도구 다운로드 [1] file 험프리 2015.11.16 1849
547 [튜토리얼] Mobile Tutorials: Mobile Application Development Humphery 2014.06.13 1848
546 RAD 스튜디오(델파이, C++빌더) 웹개발 방법(WebBroker, IntraWeb) 험프리 2016.09.07 1833
545 이 달의 기술자료 - 2021년 09월 file 험프리 2021.08.26 1813
544 손쉬운 데이터 연결 방법(라이브바인딩 활용): 파이어몽키 코스북 6장 file 관리자 2014.07.18 1808
543 RAD Studio XE6 TChart 패치의 건 Humphery 2014.07.31 1794
542 20140424_Developer Direct LIVE! 2014 세미나 세션 자료입니다. 관리자 2014.04.25 1772
541 [10.3 리오][업데이트 2] Firebase 안드로이드 앱 푸쉬 알림 - 10.3.2에서 FCM 수신 설정하기 [1] file 김원경 2019.08.21 1758
540 FireDAC 성능 비교(BDE, dbGO(ADO), dbExpress, FireDAC) 험프리 2016.08.09 1756
539 [BaaS] VCL에서 특정사용자에게 GCM/APN 전송하기(FMX도 사용가능) Humphery 2014.07.25 1727
538 [시애틀] BSON(Binary JSON)을 처리하고, JSON 데이터를 스트리밍 모델로 읽고, 쓸수 있습니다. file Humphery 2015.10.05 1720
537 [업데이트][10.2 도쿄][릴리즈 2] 10.2 도쿄 - 릴리즈 2 출시 & 설치방법 안내 file 험프리 2017.12.13 1706
536 [마이그레이션] 컴파일러 버젼 [1] 험프리 2014.08.18 1691
535 [FireDAC Skill Sprints] 6. 전처리: SQL문을 유연하게 작성할 수 있는 Param와 Macro 사용하기 Humphery 2015.03.13 1689