Sunday, 15 July 2012

Delphi XE5 Android problems locating file -



Delphi XE5 Android problems locating file -

i have problem find , open file have stored on phone pc. despite fine solution in this answer can't work. i'm running on htc sensation z710e

here code i'm trying run:

function getsdcardpath: string; var musicpathlength: integer; musicpath, sdcardpath: string; begin musicpath:=system.ioutils.tpath.getsharedmusicpath; musicpathlength:=length(musicpath); sdcardpath:=copy(musicpath, 0, musicpathlength-5); result:=sdcardpath; end; procedure tform3.button1click(sender: tobject); var sr:tsearchrec; begin cardpath:=tpath.combine(getsdcardpath,'*.*'); if (findfirst(cardpath,fanormal,sr)=0) begin repeat memo1.lines.add(sr.name); until findnext(sr)<>0; findclose(sr); end; end;

i did sec test code below , can store file filename comes in filelist, seems not stored on sdcard, @ to the lowest degree not 1 appears external drive f: on pc. tpath.getdocumentspath should point sdcard, shouldn't it?

procedure tform3.button1click(sender: tobject); var sr:tsearchrec; begin cardpath:=tpath.combine(tpath.getdocumentspath,'*.*'); memo1.lines.add(cardpath); if (findfirst(cardpath,faanyfile,sr)=0) begin repeat memo1.lines.add(sr.name); until findnext(sr)<>0; findclose(sr); end; end; procedure tform3.writeclick(sender: tobject); var s: string; f:textfile; begin memo1.lines.clear; s := tpath.combine(tpath.getdocumentspath,'file2.txt'); assignfile(f,s); rewrite(f); writeln(f,'test'); closefile(f); end;

first click write button write file , list files in directory clicking button1. cardpath /data/data/com.embarcadero.testapp2/files/. have android/data/com.embarcadero.testapp2/files/ folder visible on device pc, no file there. file stored internaly in device?

i found out how solve this. using tpath.getshareddocumentspath see file saved app on pc if device not connected drive when saving (mentioned on this page). e.i. when using app, pc can't using sdcard drive @ same time.

android delphi delphi-xe5 file-location

No comments:

Post a Comment