Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Deployment - Custom File



Permlink Replies: 7 - Last Post: Jun 8, 2015 11:07 AM Last Post By: Borja Serrano Threads: [ Previous | Next ]
Cassius Feno

Posts: 4
Registered: 1/3/05
Deployment - Custom File
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 2, 2015 2:46 PM
I need to send a file with my android app. I will name it as test.txt on this example.

What I did was put my file in Deployment area and change the Remote Path to "assets\internal".

After, I have used TPath.Combine(TPath.GetDocumentsPath(), 'test.txt') to get access on file.

But it not work!! I got a "File not Exists" message.

I did a procedure showing all files in Documents path, but I can just see files created by app, but I can't see files sent on deployment.

What am I doig wrong ? Can anyone help me ?

PS:
My tests are using Delphi XE7 on Android 4.2 and Android Lollipop

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Deployment - Custom File
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 2, 2015 2:55 PM   in response to: Cassius Feno in response to: Cassius Feno
Cassius wrote:

What I did was put my file in Deployment area and change the Remote
Path to "assets\internal".

After, I have used TPath.Combine(TPath.GetDocumentsPath(), 'test.txt')
to get access on file.

But it not work!! I got a "File not Exists" message.

Did you verify that the file was actually deployed to the device? What value
is TPath.GetDocumentsPath() actually returning for your device?

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Deployment - Custom File
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 2, 2015 3:52 PM   in response to: Cassius Feno in response to: Cassius Feno
Cassius wrote:

What I did was put my file in Deployment area and change the Remote
Path to "assets\internal".

After, I have used TPath.Combine(TPath.GetDocumentsPath(), 'test.txt')
to get access on file.

But it not work!! I got a "File not Exists" message.

Did you verify that the file was actually deployed to the device? What value
is TPath.GetDocumentsPath() actually returning for your device?

--
Remy Lebeau (TeamB)
Cassius Feno

Posts: 4
Registered: 1/3/05
Re: Deployment - Custom File
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 3, 2015 7:17 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Did you verify that the file was actually deployed to the device? What value
is TPath.GetDocumentsPath() actually returning for your device?

--
Remy Lebeau (TeamB)

Thanks for reply Remy.

TPath.GetDocumentsPath() returns "/data/data/com.embarcadero.???/files/".

I did a small app to test. On this app I put one TMemo and two buttons.
In first button I wrote a simple code to save the text of memo to a file, named "memo.txt".
On second button I put a procedure to list all files in TPath.GetDocumentsPath().

The test.txt file was sent with deployment method, to "assets\internal"

On this second button click result I can see memo.txt, but I never found the test.txt sent with deployment.

I dont known where files put in "assets\internal" goes.

---
Cassius.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Deployment - Custom File
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 3, 2015 9:18 AM   in response to: Cassius Feno in response to: Cassius Feno
Cassius wrote:

TPath.GetDocumentsPath() returns
"/data/data/com.embarcadero.???/files/".

Does it really have those question marks in it? If so, that would explain
why your file cannot be found at runtime. TPath.GetDocumentationsPath()
returns '/data/data/<application-id>/files/' on Android, and 'com.embarcadero.???'
is not what your app's application-id should be getting reported as.

TPath.GetDocumentsPath() on Android returns whatever Android's Context.getFilesDir().getPath()
method returns. So I would find that hard to believe that Android would
return a path with a corrupt appliction-id, so it makes me wonder if Embarcadero
is corrupting the value when converting it from the Android framework into
the Delphi framework.

--
Remy Lebeau (TeamB)
Cassius Feno

Posts: 4
Registered: 1/3/05
Re: Deployment - Custom File
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 3, 2015 1:43 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Cassius wrote:

TPath.GetDocumentsPath() returns
"/data/data/com.embarcadero.???/files/".

Does it really have those question marks in it? If so, that would explain
why your file cannot be found at runtime. TPath.GetDocumentationsPath()
returns '/data/data/<application-id>/files/' on Android, and 'com.embarcadero.???'
is not what your app's application-id should be getting reported as.

TPath.GetDocumentsPath() on Android returns whatever Android's Context.getFilesDir().getPath()
method returns. So I would find that hard to believe that Android would
return a path with a corrupt appliction-id, so it makes me wonder if Embarcadero
is corrupting the value when converting it from the Android framework into
the Delphi framework.

--
Remy Lebeau (TeamB)

Sorry... I put ??? as a bad example... here TPath.GetDocumentPath returns "/data/data/com.embarcadero.test/files/".

Cassius Feno

Posts: 4
Registered: 1/3/05
Re: Deployment - Custom File
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 8, 2015 9:05 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
I have created a new mobile project, saved as Project1.dpr and Unit1.pas.
On Form, I put a button and a memo.
On Button code I put:

procedure TForm1.Button1Click(Sender: TObject);
var
wFileName: string;
begin
wFileName:= TPath.Combine(TPath.GetDocumentsPath(), 'test.txt');
if FileExists(wFileName) then
Memo1.Lines.LoadFromFile(wFileName)
else
Memo1.Lines.Add('File not found: '+wFileName);
end;

On deployment screen I have choose "All Configurations - All Plataforms" and added my "test.txt" file.
On Android lines, I have changed the Remote Path to "assets\internal\"

On Target plataform I choose my 4.2 Android tablet (have tested with a Z3 with Lollipop too)

When executed and Button1 pressed I get always the else condition, with:
File not Found: /data/data/com.embarcadero.Project1/files/test.txt

I don't known with I have to do any other procedure to deploy my file.

---
Cassius
Borja Serrano

Posts: 172
Registered: 1/10/13
Re: Deployment - Custom File
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 8, 2015 11:07 AM   in response to: Cassius Feno in response to: Cassius Feno
Hello,

The problem is that you are deploying them under "All configurations". Remove the file from the Deployment and readd it under Debug and Release configurations separately and it will work.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02