LAMW: TEnvDirectory paths lazarus / 43-Android ---------------------------------------------------------------------- c4p · 2017-09-11 12:32 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! ---------------------------------------------------------------------- jmpessoa · 2017-09-11 19:48 Hi c4p! I will try fix this issues! Thank you! ---------------------------------------------------------------------- c4p · 2017-09-11 20:08 Thank you! (again) ---------------------------------------------------------------------- c4p · 2017-09-17 08:58 Really keen to get this working ( specifically dirSharedPrefs ), looking to send my app to the Play store soon. ---------------------------------------------------------------------- jmpessoa · 2017-09-19 19:54 Ok. Fixed "jDownloadManager.java"  template! Please, test it! ---------------------------------------------------------------------- c4p · 2017-09-19 21:52 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!) ---------------------------------------------------------------------- jmpessoa · 2017-09-19 22:34 QuoteI 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: QuotedirInternalAppStorage - 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(dirDown loads)+'/myfile.txt',                   Self.GetEnvironmentDirectoryPath(dirSharedPrefs)+'/myfile.txt'); ---------------------------------------------------------------------- c4p · 2017-09-20 05:43 Good point, I have a rooted phone. I will try this later. ---------------------------------------------------------------------- jmpessoa · 2017-09-20 17:35 Here are the java "APIs" [DownloadManager.Request] setDestinationInExternalPublicDir(Path, Filename); setDestinationInExternalFilesDir(context, Filename , subPath) setDestinationUri(uri)        from docs: QuoteSet 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" ... ---------------------------------------------------------------------- c4p · 2017-09-20 20:12 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. ---------------------------------------------------------------------- jmpessoa · 2017-09-20 20:37 OK, I will can rollback the [change] commited .... Thank you! NOTE: LAMW do not support "document" folder... [need API >= 19] ---------------------------------------------------------------------- c4p · 2017-09-23 21:48 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