Delphi FMX 手机目录提取,把IO相关的都提取到System.IoUtils单元中

Delphi FMX 手机目录提取,把IO相关的都提取到System.IoUtils单元中

标签:android   com   使用   代码   si   la   sp   方法   ha   

Delphi把IO相关的都提取到System.IoUtils单元中。
路径操作使用TPath的方法都很方便。
uses System.IoUtils

TPath.GetTempPath//临时目录
TPath.GetCameraPath//照相机目录(照片/录像)
TPath.GetMusicPath//音乐目录
TPath.GetDownloadsPath//下载目录
……
如果使用TPath类的静态方法那么代码就是跨平台的,在Windows,Mac,iOS,Android上都能用。如果仅仅对Android的操作也可以使用Androidapi.IOUtils单元的那些GetXX的函数,也很简单,都没有参数,并且返回值都是字符串。

可以用任何一个事件测试一下:
   showmessage(‘GetCachePath:‘ + TPath.GetPathRoot(TPath.GetCachePath));
   showmessage(‘GetTempPath:‘ + TPath.GetTempPath);
   showmessage(‘GetHomePath:‘ + TPath.GetHomePath);
   showmessage(‘GetDocumentsPath:‘ + TPath.GetDocumentsPath);    showmessage(‘GetSharedDocumentsPath:‘ + TPath.GetSharedDocumentsPath);
   showmessage(‘GetSharedPicturesPath:‘ + TPath.GetSharedPicturesPath);
   showmessage(‘GetSharedDownloadsPath:‘ + TPath.GetSharedDownloadsPath);
   showmessage(‘GetCachePath:‘ + TPath.GetCachePath);
   showmessage(‘GetCameraPath:‘ + TPath.GetCameraPath);
   showmessage(‘GetPicturesPath:‘ + TPath.GetPicturesPath);
   showmessage(‘GetPublicPath:‘ + TPath.GetPublicPath);
以下是用nubia z5手机测试的结果(都是TPath下的函数,最后都没有/):
GetRandomFileName:L8d4hdw0.W2d
GetTempFileName:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/tmp/tmp.qqvwf21410
GetTempPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/tmp
GetHomePath:/data/data/com.embarcadero.Project1/files
GetDocumentsPath:/data/data/com.embarcadero.Project1/files
GetSharedDocumentsPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files
GetLibraryPath:/data/app-lib/com.embarcadero.Project1-2
GetCachePath:/data/data/com.embarcadero.Project1/cache
GetPublicPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files
GetPicturesPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Pictures
GetSharedPicturesPath:/storage/sdcard0/Pictures
GetCameraPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/DCIM
GetSharedCameraPath:/storage/sdcard0/DCIM
GetMusicPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Music
GetSharedMusicPath:/storage/sdcard0/Music
GetMoviesPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Movies
GetAlarmsPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Alarms
GetSharedAlarmsPath:/storage/sdcard0/Alarms
GetDownloadsPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Download
GetSharedDownloadsPath:/storage/sdcard0/Download
GetRingtonesPath:/storage/sdcard0/Android/data/com.embarcadero.Project1/files/Ringtones
GetSharedRingtonesPath:/storage/sdcard0/Ringtones

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值