Page 1 of 1

What is the best way to get data from android app to pc?

Posted: Sat Nov 25, 2017 2:32 am
by T4r4ntul4
hey all,

I have data in a sql file on a android tablet. What is the best way to get it from the tablet to the pc, i dont care if its going through wifi or via a usb cable or whatever, i just want the data from the tablet to the pc, how can i do that?

All suggestions are welcome!

Re: What is the best way to get data from android app to pc?

Posted: Tue Nov 28, 2017 4:39 pm
by IdeasVacuum
The most convenient way would be Bluetooth, or your WiFi network. If not that, a simple USB cable (I connect my Android Phone via USB, it's own File Manager allows drag and drop between the two), or a USB Key.

You could also Upload the data from the Android device to your website server, and download from there.

Also Check out the free service We Transfer, it's fast and easy to use:

https://wetransfer.com/

Re: What is the best way to get data from android app to pc?

Posted: Tue Nov 28, 2017 10:06 pm
by T4r4ntul4
Hi,

Take for example this code: Where can i find the file mydb.sqlite so i can transfer it to pc?

Code: Select all

Procedure CreateFileCallback(Status, Filename$, File, SizeRead)
  Select Status
    Case #PB_Status_Saved
      Debug "File saved: " + Filename$ + "(" + SizeRead + " bytes)"
     
    Case #PB_Status_Error
      Debug "Can't save the file: " + Filename$
  EndSelect
EndProcedure


Procedure PerformQuery(DB)
  If DatabaseQuery(DB, "Select * From SuperHeroes Where Prename = 'Peter'")
    While NextDatabaseRow(DB)
      Debug GetDatabaseString(DB, 1) + "," + GetDatabaseString(DB, 0)
    Wend
   
    FinishDatabaseQuery(DB)
  Else
    Debug "DatabaseQuery() failed: " + DatabaseError()
  EndIf 
EndProcedure


Procedure ReadFileCallback(Status, Filename$, File, SizeRead)
  Select Status
    Case #PB_Status_Loaded
      Debug "File loaded: " + Filename$
     
      ; Get all the file as a new buffer
      *Buffer = ExportFileMemory(File)
      Debug MemorySize(*Buffer)
     
      DB = OpenDatabase(#PB_Any, *Buffer)
      If DB
        Debug "OpenDatabase() read from file: OK"
        PerformQuery(DB)
      EndIf
     
    Case #PB_Status_Error
      Debug "Can't read the file: " + Filename$
      Debug "Creating a new database"
     
      DB = OpenDatabase(#PB_Any)
      If DB
        Debug "OpenDatabase(): OK"
       
        DatabaseUpdate(DB, "Create Table SuperHeroes (Prename TEXT, Surname TEXT)")
       
        DatabaseUpdate(DB, "Insert Into SuperHeroes (Prename, Surname) Values ('Peter', 'Parker')")
        DatabaseUpdate(DB, "Insert Into SuperHeroes (Prename, Surname) Values ('Peter', 'Jackson')")
        DatabaseUpdate(DB, "Insert Into SuperHeroes (Prename, Surname) Values ('Bruce', 'Wayne')")
        DatabaseUpdate(DB, "Insert Into SuperHeroes (Prename, Surname) Values ('Clark', 'Kent')")
       
        PerformQuery(DB)
       
        ; Now save the database to a persistent file
        ;
        *Buffer = ExportDatabaseMemory(DB)
        If CreateFile(0, "mydb.sqlite", @CreateFileCallback(), #PB_LocalStorage)
          WriteData(0, *Buffer, 0, MemorySize(*Buffer))
          CloseFile(0)
        EndIf
       
        CloseDatabase(DB)
      Else
        Debug "OpenDatabase() failed"
      EndIf
  EndSelect
EndProcedure

; Try to read the database if already present, or it will create a new one
;
ReadFile(0, "mydb.sqlite", @ReadFileCallback(), #PB_LocalStorage) 

Re: What is the best way to get data from android app to pc?

Posted: Wed Dec 06, 2017 1:26 pm
by Fred
You could try to upload your file on your server and get it back with an url on your PC

Re: What is the best way to get data from android app to pc?

Posted: Wed Dec 06, 2017 2:22 pm
by T4r4ntul4
But where do i get that file? I cant find it with the file explorer on android, or as it is connected with the pc?
How do i get that file? Where can i find it?

Re: What is the best way to get data from android app to pc?

Posted: Wed Dec 06, 2017 7:38 pm
by Fred
It's stored in the the browser localstorage, so it's not on the android filesystem. You can try to send the memory buffer to the server, or try an ExportFile() which should trigger a downloadfrom the android app.

Re: What is the best way to get data from android app to pc?

Posted: Wed Dec 06, 2017 9:29 pm
by T4r4ntul4
I tried already a ExportFile() on android but nothing happens.

Re: What is the best way to get data from android app to pc?

Posted: Tue Dec 12, 2017 1:06 am
by T4r4ntul4
Fred wrote:or try an ExportFile() which should trigger a download from the android app.
Can someone test this out? maybe its just me, but nothing happens with that in android.

Re: What is the best way to get data from android app to pc?

Posted: Wed Dec 20, 2017 9:43 pm
by T4r4ntul4
T4r4ntul4 wrote:Can someone test this out? maybe its just me, but nothing happens with that in android.
*bump*