Lazarus

Programming => Operating Systems => Android => Topic started by: las on May 17, 2019, 08:43:34 pm

Title: jTextFileManager bugs and wishes
Post by: las on May 17, 2019, 08:43:34 pm
Hi!
The jTextFileManager turned out to be very inconvenient to use. It has two options for the SaveToFile and LoadFromFile functions. In this case, the option that saves to the specified directory, saves generally unclear where. Therefore, you can use only the option that saves without specifying the path. But when reading a file, it merges all the lines into one, because it does not insert line breaks.
I would also like to have functions for viewing the list of files and deleting unnecessary ones.
SaveToFile without specifying the path saves the data in the Files directory, I would like to be able to save some files in the Cache directory so that the system can clean it safely.
Title: Re: jTextFileManager bugs and wishes
Post by: jmpessoa on May 18, 2019, 04:59:56 am
Done!
Added dirCache to "TEnvDirectory"

Sample code:
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  2. var
  3.   list: TStringList;
  4.   arrayFilename: TDynArrayOfString;
  5.   i, count: integer;
  6. begin
  7.  
  8.   list:= TStringList.Create;
  9.  
  10.   list.Add('Hello');
  11.   list.Add('Lazarus');
  12.   list.Add('Android');
  13.   list.Add('World!');
  14.  
  15.   ShowMessage(Self.GetEnvironmentDirectoryPath(dirCache));
  16.  
  17.   jTextFileManager1.SaveToFile(list.Text, Self.GetEnvironmentDirectoryPath(dirCache),'test1.txt');
  18.  
  19.   jTextFileManager1.SaveToFile(list.Text,dirCache,'test2.txt');
  20.  
  21.   ShowMessage(jTextFileManager1.LoadFromFile(Self.GetEnvironmentDirectoryPath(dirCache),'test2.txt'));
  22.  
  23.   list.SaveToFile(Self.GetEnvironmentDirectoryPath(dirCache)+'/test3.txt');
  24.   list.LoadFromFile(Self.GetEnvironmentDirectoryPath(dirCache)+'/test3.txt');
  25.   ShowMessage(list.Text);
  26.  
  27.   arrayFilename:= Self.GetFileList(Self.GetEnvironmentDirectoryPath(dirCache));
  28.   count:= length(arrayFilename);
  29.   for i:= 0 to count-1 do
  30.   begin
  31.      ShowMessage(arrayFilename[i]);
  32.   end;
  33.  
  34.   //jOpenDialog1.Show(dirCache, 'txt');  //visual file lists
  35.  
  36.   Setlength(arrayFilename, 0); //free
  37.   list.Free;
  38.  
  39. end;
  40.  
  41.  

Note: "dirCache" is intern app storage... so, we don't need "runtime permission"
TinyPortal © 2005-2018