RishiKumar2210
Active Member
Hi Guys. I want to Retrieve A Pdf File I saved in a database. I saved Pdf File through following steps.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Now I don't Know How to retrieve the record?
			
			
			
				B4X:
			
		
		
		' Selecting File Through ContentChooser
cc.Show("*/*", "Choose File")
    Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
    If Success Then
        'getFileInfo(FileName)
        ilbl_filename.Text = GetFileInfoByIndex("_display_name", FileName)
        
        is_filename = FileName
        is_dir = Dir
    
        is_imageextension = ilbl_filename.Text.Trim
        is_imageextension = is_imageextension.SubString2(is_imageextension.LastIndexof("."), is_imageextension.Length)
        is_imageextension = is_imageextension.SubString2(1,is_imageextension.Length)
        Log("Extension : " & is_imageextension)
    End If
    
    'Get File Name And Directory
    Sub GetFileInfoByIndex(column As String, uri As String) As String
    Dim results As String
    Dim Cur As Cursor
    Dim Uri1 As Uri
    Dim cr As ContentResolver
    cr.Initialize("")
    'if viewing by gallery
    If uri.StartsWith("content://media/") Then
          Dim i As Int = uri.LastIndexOf("/")
          Dim id As String = uri.SubString(i + 1)
          Uri1.Parse(uri)
          Cur = cr.Query(Uri1, Null, "_id = ?", Array As String(id), Null)
    Cur.Position = 0
        If Cur.RowCount <> 0 Then
            For i = 0 To Cur.ColumnCount - 1
                If Cur.GetColumnName(i) <> Null Then
                    If Cur.GetColumnName(i) = column Then
                        results = Cur.GetString2(i)
                        Exit
                    End If
                End If
            Next
        End If
    Else
        Uri1.Parse(uri)
        Cur = cr.Query(Uri1, Null, Null, Null, Null)
        Cur.Position = 0
        If Cur.RowCount <> 0 Then
            For i = 0 To Cur.ColumnCount - 1
                If Cur.GetColumnName(i) <> Null Then
                    If Cur.GetColumnName(i) = column Then
                        results = Cur.GetString2(i)
                        Exit
                    End If
                End If
            Next
        End If
    End If
    
    'Converting PDF File Into Bytes And Then Encode it Into String And Then Save As String into Database.
    
    Dim ls_byte() As Byte
    ls_byte = FileToBytes(is_dir, is_filename)
            
    Log("file name : " & is_filename)
            
    Dim ls_stringutils As StringUtils
    ls_photostring = ls_stringutils.EncodeBase64(ls_byte)
    
    Cur.Close
    
    Return results
    
End SubNow I don't Know How to retrieve the record?
 
				 
 
		 
 
		 
 
		 
 
		 
						
					 
 
		