Recent

Author Topic: Using getExternalStorageDirectory under LazToApk.  (Read 3641 times)

olesio

  • Newbie
  • Posts: 2
Using getExternalStorageDirectory under LazToApk.
« on: March 19, 2015, 05:33:44 pm »
Hello.

I am totally Newbie in LazToApk. I try to prepare simple application to use under Android KitKat on my Lenovo Yoga 2 Tablet.

I want to crate application which read KODI log files and extract urls from them. I can do something like that
Code: [Select]
if FileExistsUTF8('/sdcard/Android/data/org.xbmc.kodi/files/.kodi/temp/kodi.log') then
//....
But that "/sdcard/" or other begin of path may be different on different devices, so I need to use something universal. And I found in Google there is function named getExternalStorageDirectory.

But I do not know how to use it without compile errors. I see that function is in source file in:
Code: [Select]
C:\LAZTOAPK\downloads\laz4android\fpc\2.7.1\source\rtl\android\jvm\androidr14.pasBut when I add androidr14 to uses section it was not seen by Lazarus IDE under LazToApk. So I added this file in Project Inspector. But I got compile errors on lines like...
Code: [Select]
JLStringBuffer = class external 'java.lang' name 'StringBuffer';Etc. And I do not know how to fix it. Please explain me step by step how to be able to use getExternalStorageDirectory in my code or other units. I have only customdraw package included and installed like in pdf file manual with LazToApk installation guide.

Thanks for help in advance and sorry for my bad English. Best regards - olesio.
« Last Edit: March 19, 2015, 05:35:23 pm by olesio »

OldSchoolProgrammer

  • Newbie
  • Posts: 3
Re: Using getExternalStorageDirectory under LazToApk.
« Reply #1 on: July 26, 2015, 09:33:19 am »
My suggestion is to use... GetEnvironmentVariable('EXTERNAL_STORAGE')

On my cell phone (LG Optimus running Gingerbread 2.3.4)
and in the emulator (targeting API 10)
the string returned is... '/mnt/sdcard'

Test it on a wide variety of devices and see it's what you were hoping for.
Don't you wish LIFE was as simple as... writing source code?

olesio

  • Newbie
  • Posts: 2
Re: Using getExternalStorageDirectory under LazToApk.
« Reply #2 on: July 27, 2015, 01:56:22 am »
Thank you for reply. I wrote app in XE 8 anyway, but it take much free space and debug apk have big size about 7 MB. Anyway, I hope after update on my Tablet to Lolipop apps in LazToApk still will be work fine, because some from XE 8 wont.

DelphiFreak

  • Sr. Member
  • ****
  • Posts: 255
    • Fresh sound.
Re: Using getExternalStorageDirectory under LazToApk.
« Reply #3 on: August 02, 2015, 12:10:06 pm »
Hello olesio,

I just would like to explain, what laztoapk is.
It is a helper tool & setup which tries to make the configuration of all this SDK,JDK,NDK,lazarus,FPC,customdrawn stuff a little simpler. ( actually it generates batch-files )
The real hard work is done by FPC/laz4android. It compiles your app into a .so file.

So if some functionality is available or not, does not depend on the laztoapk. It has more to do with laz4android/FPC/customdrawn.   

Have fun,
Sam
Linux Mint 20.3, Lazarus 2.3, Windows 10, Delphi 10.3 Rio, Delphi 11.1 Alexandria

 

TinyPortal © 2005-2018