Get PhoneId.GetDeviceId from server

sigster

Active Member
Licensed User
Longtime User
Hi do anyone know how I fix his Please , Thanks

I am try to get textfile with same name and DeviceId and save it to my mobile
it save the name on my mobile = & PhoneId.GetDeviceId & .txt
not like = 000000000000000.txt

Regards
Sigster

This is in button in LoadLayout("getfile")
B4X:
   DownloadService.URL = "http://URL/" & PhoneId.GetDeviceId  & ".txt"

   DownloadService.Target = File.OpenOutput(File.DirDefaultExternal,"& PhoneId.GetDeviceId  & .txt", False)
   StartService(DownloadService)

this is when form start to check if I have the file or not
B4X:
   If File.Exists(File.DirDefaultExternal,"& PhoneId.GetDeviceId  & .txt") Then
   
      ToastMessageShow("the file is on your Mobile", True)
   
         Else
         ToastMessageShow("No file", True)
                         
      RemoveViews
      Activity.LoadLayout("getfile")   
      
   End If
 

Ohanian

Active Member
Licensed User
Longtime User
Hi do anyone know how I fix his Please , Thanks

I am try to get textfile with same name and DeviceId and save it to my mobile
it save the name on my mobile = & PhoneId.GetDeviceId & .txt
not like = 000000000000000.txt

Regards
Sigster

This is in button in LoadLayout("getfile")
B4X:
   DownloadService.URL = "http://URL/" & PhoneId.GetDeviceId  & ".txt"

   DownloadService.Target = File.OpenOutput(File.DirDefaultExternal,"& PhoneId.GetDeviceId  & .txt", False)
   StartService(DownloadService)

this is when form start to check if I have the file or not
B4X:
   If File.Exists(File.DirDefaultExternal,"& PhoneId.GetDeviceId  & .txt") Then
   
      ToastMessageShow("the file is on your Mobile", True)
   
         Else
         ToastMessageShow("No file", True)
                         
      RemoveViews
      Activity.LoadLayout("getfile")   
      
   End If

Hi,

it think you should fix your code like this :

B4X:
DownloadService.Target = File.OpenOutput(File.DirDefaultExternal, PhoneId.GetDeviceId & ".txt", False)
B4X:
If File.Exists(File.DirDefaultExternal,PhoneId.GetDeviceId & ".txt")

or

B4X:
DownloadService.Target = File.OpenOutput(File.DirDefaultExternal, "PhoneId.GetDeviceId.txt", False)
 
Last edited:
Upvote 0

sigster

Active Member
Licensed User
Longtime User
This works thanks

I call PhoneId.GetDeviceId in DownloadService.URL and DownloadService.Target
so if the file is not on the server DownloadService.Target make a new one

there is no check if the file "PhoneId.GetDeviceId" is on the server and then download it

Regards
Sigster
 
Upvote 0
Top