Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: [X10-FMX-Android]Save or read file on Android


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 10 - Last Post: Jan 15, 2016 12:11 PM Last Post By: Remy Lebeau (Te...
Mario Gagne

Posts: 93
Registered: 2/17/12
[X10-FMX-Android]Save or read file on Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 14, 2016 6:54 AM
Hi

{$IFDEF ANDROID}

// FDONNEES.DonneesConnection.Params.Values['Database'] :=TPath.Combine(TPath.GetDocumentsPath, 'donnee.db'); for Sqlite is ok

// for files or picture

// Fstat.ImageViewer2.Bitmap.LoadFromFile(TPath.Combine(TPath.GetDocumentsPath,image.text +'.jpg')); for load error

s := GetHomePath + PathDelim + 'Documents' + PathDelim + image.text+'.png' ;

{$ENDIF}
// for wimdows
// S := 'c:\00android\test.png'; ok

What command use for load or save in my Android phone.

I read

For Android, set the Remote Path to assets\internal ==>assets\internal\
For iOS, set the Remote Path to StartUp\Documents ==>StartUp\Documents\

Thank for your help

Mario

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: [X10-FMX-Android]Save or read file on Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 14, 2016 10:27 AM   in response to: Mario Gagne in response to: Mario Gagne
Mario wrote:

Fstat.ImageViewer2.Bitmap.LoadFromFile(TPath.Combine(TPath.GetDocumentsPath,image.text
+'.jpg')); for load error

Have you tried TPath.GetPicturesPath() or TPath.GetSharedPicturesPath() yet?

For Android, set the Remote Path to assets\internal
==>assets\internal\

TPath.GetDocumentsPath() should work for that path.

--
Remy Lebeau (TeamB)

Mario Gagne

Posts: 93
Registered: 2/17/12
Re: [X10-FMX-Android]Save or read file on Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 14, 2016 5:10 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Mario wrote:

Fstat.ImageViewer2.Bitmap.LoadFromFile(TPath.Combine(TPath.GetDocumentsPath,image.text
+'.jpg')); for load error

Have you tried TPath.GetPicturesPath() or TPath.GetSharedPicturesPath() yet?

For Android, set the Remote Path to assets\internal
==>assets\internal\

TPath.GetDocumentsPath() should work for that path.

My command is

ImageViewer1.Bitmap.SaveToFile(TPath.GetDocumentsPath+ PathDelim + 'test.bmp');

I test this command but I have error Failed recording bitmap.

Do you have a good command to write and load picture

Thank a lot

Mario
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: [X10-FMX-Android]Save or read file on Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 15, 2016 10:35 AM   in response to: Mario Gagne in response to: Mario Gagne
Am 15.01.2016 um 02:10 schrieb Mario Gagne:
Remy Lebeau (TeamB) wrote:
Mario wrote:

Fstat.ImageViewer2.Bitmap.LoadFromFile(TPath.Combine(TPath.GetDocumentsPath,image.text
+'.jpg')); for load error

Have you tried TPath.GetPicturesPath() or TPath.GetSharedPicturesPath() yet?

For Android, set the Remote Path to assets\internal
==>assets\internal\

TPath.GetDocumentsPath() should work for that path.

My command is

ImageViewer1.Bitmap.SaveToFile(TPath.GetDocumentsPath+ PathDelim + 'test.bmp');

I test this command but I have error Failed recording bitmap.

Do you have a good command to write and load picture

Thank a lot

Mario

Hello,

does it happen as well if you call it like this:

ImageViewer1.Bitmap.SaveToFile(TPath.Combine(TPath.GetDocumentsPath+,
'test.bmp');

And which version of Delphi are you using?

Greetings

Markus
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: [X10-FMX-Android]Save or read file on Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 15, 2016 11:39 AM   in response to: Markus Humm in response to: Markus Humm
Markus wrote:

does it happen as well if you call it like this:

That should be this instead:

TPath.Combine(TPath.GetDocumentsPath,'test.bmp') // no + after GetDocumentsPath


And if you look at the original message in this discussion, Mario already
tried TPath.Combine():

// Fstat.ImageViewer2.Bitmap.LoadFromFile(TPath.Combine(TPath.GetDocumentsPath,image.text
+'.jpg')); for load error

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


Posts: 9,447
Registered: 12/23/01
Re: [X10-FMX-Android]Save or read file on Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 15, 2016 11:41 AM   in response to: Mario Gagne in response to: Mario Gagne
Mario wrote:

Fstat.ImageViewer2.Bitmap.LoadFromFile(TPath.Combine(TPath.GetDocument
sPath,image.text +'.jpg')); for load error

// for wimdows
// S := 'c:\00android\test.png'; ok

What is the actual string value being reported as on your Android device?

s := TPath.Combine(TPath.GetDocumentsPath, image.text + '.jpg');
// what is the value of 's' here?
Fstat.ImageViewer2.Bitmap.LoadFromFile(s);


--
Remy Lebeau (TeamB)
Mario Gagne

Posts: 93
Registered: 2/17/12
Re: [X10-FMX-Android]Save or read file on Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 15, 2016 11:49 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Mario wrote:

Fstat.ImageViewer2.Bitmap.LoadFromFile(TPath.Combine(TPath.GetDocument
sPath,image.text +'.jpg')); for load error

// for wimdows
// S := 'c:\00android\test.png'; ok

What is the actual string value being reported as on your Android device?

s := TPath.Combine(TPath.GetDocumentsPath, image.text + '.jpg');
// what is the value of 's' here?
Fstat.ImageViewer2.Bitmap.LoadFromFile(s);


--
Remy Lebeau (TeamB)
Mario Gagne

Posts: 93
Registered: 2/17/12
Re: [X10-FMX-Android]Save or read file on Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 15, 2016 11:49 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Mario wrote:

Fstat.ImageViewer2.Bitmap.LoadFromFile(TPath.Combine(TPath.GetDocument
sPath,image.text +'.jpg')); for load error

// for wimdows
// S := 'c:\00android\test.png'; ok

What is the actual string value being reported as on your Android device?

s := TPath.Combine(TPath.GetDocumentsPath, image.text + '.jpg');
// what is the value of 's' here?
Fstat.ImageViewer2.Bitmap.LoadFromFile(s);


--
Remy Lebeau (TeamB)
Mario Gagne

Posts: 93
Registered: 2/17/12
Re: [X10-FMX-Android]Save or read file on Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 15, 2016 11:49 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Mario wrote:

Fstat.ImageViewer2.Bitmap.LoadFromFile(TPath.Combine(TPath.GetDocument
sPath,image.text +'.jpg')); for load error

// for wimdows
// S := 'c:\00android\test.png'; ok

What is the actual string value being reported as on your Android device?

s := TPath.Combine(TPath.GetDocumentsPath, image.text + '.jpg');
// what is the value of 's' here?
Fstat.ImageViewer2.Bitmap.LoadFromFile(s);


--
Remy Lebeau (TeamB)
Mario Gagne

Posts: 93
Registered: 2/17/12
Re: [X10-FMX-Android]Save or read file on Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 15, 2016 11:54 AM   in response to: Mario Gagne in response to: Mario Gagne
Mario Gagne wrote:
Remy Lebeau (TeamB) wrote:
Mario wrote:

Fstat.ImageViewer2.Bitmap.LoadFromFile(TPath.Combine(TPath.GetDocument
sPath,image.text +'.jpg')); for load error

// for wimdows
// S := 'c:\00android\test.png'; ok

What is the actual string value being reported as on your Android device?

s := TPath.Combine(TPath.GetDocumentsPath, image.text + '.jpg');
// what is the value of 's' here?
Fstat.ImageViewer2.Bitmap.LoadFromFile(s);


--
Remy Lebeau (TeamB)

Thank for your help

I test a simple programm
uses system.IOUtils;
procedure TForm2.Button1Click(Sender: TObject);
begin
 //memo
   memo2.Lines.LoadFromFile(TPath.GetDocumentsPath + '/test.txt');
   DocPathLabel.Text := TPath.GetDocumentsPath;
end;
 
 
procedure TForm2.Button2Click(Sender: TObject);
begin
//memo
   Memo1.Lines.SaveToFile(GetHomePath + '/test.txt');
   DocPathLabel.Text := TPath.GetDocumentsPath;
end;
 
procedure TForm2.Button3Click(Sender: TObject);
begin
//image
   ImageViewer2.Bitmap.LoadFromFile(TPath.GetPicturesPath + PathDelim +  '/test.png');
   Label1.Text := TPath.GetDocumentsPath;
end;
 
procedure TForm2.Button4Click(Sender: TObject);
begin
//image
    ImageViewer1.Bitmap.SaveToFile(TPath.GetPicturesPath  + PathDelim + '/test.png');
    Label1.Text := TPath.GetDocumentsPath;
end;


for the memo test it is Ok but for de picture I have problem I don't have error but I don't see my picture in imageviewer2

I use Radstudio 10 upgrade 1 (last version)

Thank again
Mario
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: [X10-FMX-Android]Save or read file on Android  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 15, 2016 12:11 PM   in response to: Mario Gagne in response to: Mario Gagne
Mario wrote:

I test a simple programm
<snip>
for the memo test it is Ok but for de picture I have problem

You did not answer my question:

What is the actual string value being reported as [by TPath.GetDocumentsPath]
on your Android device?

In any case, you are not doing the same thing with the picture loading that
you are doing with the memo loading. Your are formatting the paths differently.
Please make them match and try again:

uses
  system.IOUtils;
 
procedure TForm2.Button1Click(Sender: TObject);
var
  s: string;
begin
  //memo
  s := TPath.GetDocumentsPath + '/test.txt'; // <- what is this value being 
set to?
  memo2.Lines.LoadFromFile(s);
  DocPathLabel.Text := TPath.GetDocumentsPath;
end;
 
procedure TForm2.Button2Click(Sender: TObject);
var
  s: string;
begin
  //memo
  s := GetHomePath + '/test.txt'; // <- what is this value being set to?
  Memo1.Lines.SaveToFile(s);
  DocPathLabel.Text := TPath.GetDocumentsPath; // why GetDocumentsPath?
end;
 
procedure TForm2.Button3Click(Sender: TObject);
var
  s: string;
begin
  //image
  s := TPath.GetPicturesPath + '/test.png'; // <- what is this value being 
set to?
  ImageViewer2.Bitmap.LoadFromFile(s);
  Label1.Text := TPath.GetDocumentsPath; // why GetDocumentsPath?
end;
 
procedure TForm2.Button4Click(Sender: TObject);
var
  s: string;
begin
  //image
  s := TPath.GetPicturesPath + '/test.png'; // <- what is this value being 
set to?
  ImageViewer1.Bitmap.SaveToFile(s);
  Label1.Text := TPath.GetDocumentsPath; // why GetDocumentsPath?
end;


I don't have error but I don't see my picture in imageviewer2

Can't answer that without knowing if the problem is in the path strings you
are formatting for LoadFromFile/SaveToFile, or if the problem is inside of
FireMonkey itself. Have you tried debugging your code yet? Have you tried
stepping into FireMonkey's source code with the debugger to see what it is
actually doing?

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02