Recent

Author Topic: LAMW: TEnvDirectory paths  (Read 4954 times)

c4p

  • Full Member
  • ***
  • Posts: 157
LAMW: TEnvDirectory paths
« on: September 11, 2017, 02:32:16 pm »
Unless I am doing something wrong, this is what I get using jDownloadManager component with the TEnvDirectory paths.
I am using latest svn:

dirSdCard - DOES NOT WORK, goes to /Downloads
dirInternalAppStorage - DOES NOT WORK, goes to /Downloads
dirDatabase - DOES NOT WORK, goes to /Downloads
dirSharedPrefs -  DOES NOT WORK, goes to /Downloads

dirDownloads - Works! goes to /Downloads
dirDCIM - Works! goes to /DCIM
dirMusic - Works! goes to /Music
dirPictures - Works! goes to /Pictures
dirNotifications - Works! goes to /Notifications
dirMovies - Works! goes to /Movies
dirPodcasts - Works! goes to /Podcasts
dirRingtones - Works! goes to /Ringtones

P.S. jDownloadManager component works really well apart from the above issues!
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LAMW: TEnvDirectory paths
« Reply #1 on: September 11, 2017, 09:48:25 pm »

Hi c4p!

I will try fix this issues!

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

c4p

  • Full Member
  • ***
  • Posts: 157
Re: LAMW: TEnvDirectory paths
« Reply #2 on: September 11, 2017, 10:08:43 pm »
Thank you! (again)  :)
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

c4p

  • Full Member
  • ***
  • Posts: 157
Re: LAMW: TEnvDirectory paths
« Reply #3 on: September 17, 2017, 10:58:14 am »
Really keen to get this working ( specifically dirSharedPrefs ), looking to send my app to the Play store soon.  :)
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LAMW: TEnvDirectory paths
« Reply #4 on: September 19, 2017, 09:54:42 pm »


Ok. Fixed "jDownloadManager.java"  template!

Please, test it!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

c4p

  • Full Member
  • ***
  • Posts: 157
Re: LAMW: TEnvDirectory paths
« Reply #5 on: September 19, 2017, 11:52:13 pm »
Getting this:
dirSdCard: /storage/emulated/0/storage/emulated/0
dirInternalAppStorage: /storage/emulated/0/data/data/com.your.packagename/files
dirDatabase: /storage/emulated/0/data/data/com.your.packagename/database
dirSharedPrefs: /storage/emulated/0/data/data/com.your.packagename/shared_prefs

com.your.packagename is correct package name though!
I think /data/data/ should be /Android/data/ ?
I might have a go at fixing this myself  :)

Thank you jmpessoa (again!)
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LAMW: TEnvDirectory paths
« Reply #6 on: September 20, 2017, 12:34:10 am »
Quote
I think /data/data/ should be /Android/data/ ?

No.  "/data/data/" is Ok!

Question 1:

dirInternalAppStorage
dirDatabase
dirSharedPrefs

are internal app storages! 

So,  only your application can "read" and "write" them...

Question 2: Can jDownloadManager write there? [maybe not!]
So, we need redirect to "Downloads"

that is:

Quote
dirInternalAppStorage - DOES NOT WORK, goes to /Downloads
dirDatabase - DOES NOT WORK, goes to /Downloads
dirSharedPrefs -  DOES NOT WORK, goes to /Downloads

We will need some tests!!!

[workaround]

After download your file, copy it to "SharedPrefs"

Code: [Select]
  Self.CopyFile(Self.GetEnvironmentDirectoryPath(dirDownloads)+'/myfile.txt',
                  Self.GetEnvironmentDirectoryPath(dirSharedPrefs)+'/myfile.txt');
« Last Edit: September 20, 2017, 01:14:08 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

c4p

  • Full Member
  • ***
  • Posts: 157
Re: LAMW: TEnvDirectory paths
« Reply #7 on: September 20, 2017, 07:43:40 am »
Good point, I have a rooted phone.
I will try this later.
« Last Edit: September 20, 2017, 07:51:24 am by c4p »
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LAMW: TEnvDirectory paths
« Reply #8 on: September 20, 2017, 07:35:12 pm »
Here are the java "APIs" [DownloadManager.Request]

setDestinationInExternalPublicDir(Path, Filename);
setDestinationInExternalFilesDir(context, Filename , subPath)
setDestinationUri(uri)       

from docs:
Quote
Set the local destination for the downloaded file to a path within the PUBLIC EXTERNAL storage directory

So, after your tests I will can rollback the [change] commited ....

And we will need go by  the "workaround" ...
« Last Edit: September 20, 2017, 07:39:17 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

c4p

  • Full Member
  • ***
  • Posts: 157
Re: LAMW: TEnvDirectory paths
« Reply #9 on: September 20, 2017, 10:12:48 pm »
Not getting very good results, tried the new paths /data/data/.../files but cannot delete file (I need this to be sure I am using the correct file) using self.deletefile(dirInternalAppStorage, filename) like you can with say dirDownloads/dirNotifications.
Also tried creating new TEnvDirectory 'dirDocuments' ( /storage/emulated/0//Documents ) but cannot delete file there either. I must be missing another routine with this.
Decided to stick with dirDownloads for now.  :(
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LAMW: TEnvDirectory paths
« Reply #10 on: September 20, 2017, 10:37:25 pm »

OK, I will can rollback the [change] commited ....

Thank you!

NOTE: LAMW do not support "document" folder... [need API >= 19]
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

c4p

  • Full Member
  • ***
  • Posts: 157
Re: LAMW: TEnvDirectory paths
« Reply #11 on: September 23, 2017, 11:48:05 pm »
CopyFile will not copy to anywhere other than /Notifications, /Music etc. but FileCopy function works great!
Will copy to /data/data/com.your.packagename/files

http://wiki.freepascal.org/File_Handling_In_Pascal#FileCopy
« Last Edit: September 24, 2017, 12:25:24 am by c4p »
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

 

TinyPortal © 2005-2018