i use this code to delete a file but even after deleting using this code iam still gettting the oldfter please help . i there a way of refreshing
here is the whole code
B4X:
Dim FilePath2 As String = File.Combine(File.DirRootExternal, "Download/P5WORK.PDF")
Dim FileName As String = "P5WORK.PDF"
File.Delete(FilePath2, FileName)
here is the whole code
B4X:
Dim FilePath2 As String = File.Combine(File.DirRootExternal, "Download/P5WORK.PDF")
Dim FileName As String = "P5WORK.PDF"
File.Delete(FilePath2, FileName)
Dim Phone As Phone
If Phone.SdkVersion <= 18 Then
Dim i As Intent
i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", "file://" & FilePath2)
Dim p As Phone
p.SendBroadcastIntent(i)
Else
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim MediaScannerConnection As JavaObject
MediaScannerConnection.InitializeStatic("android.media.MediaScannerConnection")
Dim interface As Object = MediaScannerConnection.CreateEventFromUI("android.media.MediaScannerConnection.OnScanCompletedListener", "ScanCompleted", _
Null)
MediaScannerConnection.RunMethod("scanFile", Array(ctxt, Array As String(FilePath2), Array As String("image/pdf"), interface))
End If
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Link)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim out As OutputStream = File.OpenOutput(File.DirInternal, "P5WORK.PDF", False)
File.Copy2(j.GetInputStream, out)
out.Close
Dim rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then
File.Copy(File.DirInternal, "P5WORK.PDF", File.DirRootExternal, "Download/P5WORK.PDF")
Dim FilePath As String = File.Combine(File.DirRootExternal, "Download/P5WORK.PDF")
Dim Phone As Phone
If Phone.SdkVersion <= 18 Then ' min - 4.3.1
Dim i As Intent
i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", "file://" & FilePath)
Phone.SendBroadcastIntent(i)
Else
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim MediaScannerConnection As JavaObject
MediaScannerConnection.InitializeStatic("android.media.MediaScannerConnection")
Dim interface As Object = MediaScannerConnection.CreateEventFromUI("android.media.MediaScannerConnection.OnScanCompletedListener", "ScanCompleted", _
Null)
MediaScannerConnection.RunMethod("scanFile", Array(ctxt, Array As String(FilePath), Array As String("image/pdf"), interface))
End If
End If
End If