Recent

Author Topic: Is edittext1.loadfromfile('....txt') affected in api 30?  (Read 361 times)

rsu333

  • Jr. Member
  • **
  • Posts: 98
Is edittext1.loadfromfile('....txt') affected in api 30?
« on: June 07, 2022, 04:55:35 pm »
I want to load a single line text file in to edittext1 but it not probably loading as it was work in pervious app [api 29 ] .
 Also May be one more thing
var
  txtContent: string;   
begin
txtContent:= TextFileManager1.LoadFromAssets('nm.txt');

     edittext1.text:=txtContent;
may not working.
 Kindly suggest solution.
 

loaded

  • Hero Member
  • *****
  • Posts: 602
Re: Is edittext1.loadfromfile('....txt') affected in api 30?
« Reply #1 on: June 07, 2022, 08:45:48 pm »
This process required some modification of the relevant demo.
Regarding this process, let's first modify the AppOpenFileDialogDemo1 demo a bit.
Let's add the jEditText1 component to the demo. Then, let's update the jOpenDialog1FileSelected method as follows.
Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jOpenDialog1FileSelected(Sender: TObject; path: string; fileName: string);
  2. var
  3.   Stream:TFileStream;
  4.   filemergestring:string;
  5. begin
  6.    if IsRuntimePermissionGranted('android.permission.WRITE_EXTERNAL_STORAGE') then
  7.    begin
  8.       if Pos('.txt', filename) > 0 then
  9.       begin
  10.         stream:=TFileStream.Create(path+'/' + fileName,fmOpenRead or  fmShareDenyNone);  stream.Position:=0;
  11.         setLength(filemergestring,stream.Size);
  12.         stream.ReadBuffer(pointer(filemergestring)^, stream.Size);
  13.         stream.Free;
  14.         jEditText1.Text:=filemergestring;
  15.       end;
  16.    end;
  17. end;  
If Ide=Lazarus 2.0.10 32 Bit and Os=Win 10 Home 64 Bit then Get up and do something useful! Because God is the helper of those who start again;

rsu333

  • Jr. Member
  • **
  • Posts: 98
Re: Is edittext1.loadfromfile('....txt') affected in api 30?
« Reply #2 on: June 08, 2022, 08:50:57 am »
Ok, Thanks
I will try & inform you soon.

 

TinyPortal © 2005-2018