Just starting out? Need help? Post your questions and find answers here.
User avatar
T4r4ntul4
 
Posts: 117
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands

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

by T4r4ntul4 Sat Nov 25, 2017 2:32 am

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!
IdeasVacuum
 
Posts: 135
Joined: Tue Feb 25, 2014 1:27 pm

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

by IdeasVacuum Tue Nov 28, 2017 4:39 pm

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/
User avatar
T4r4ntul4
 
Posts: 117
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands

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

by T4r4ntul4 Tue Nov 28, 2017 10:06 pm

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)
Fred
Site Admin
 
Posts: 1013
Joined: Mon Feb 24, 2014 10:51 am

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

by Fred Wed Dec 06, 2017 1:26 pm

You could try to upload your file on your server and get it back with an url on your PC
User avatar
T4r4ntul4
 
Posts: 117
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands

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

by T4r4ntul4 Wed Dec 06, 2017 2:22 pm

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?
Fred
Site Admin
 
Posts: 1013
Joined: Mon Feb 24, 2014 10:51 am

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

by Fred Wed Dec 06, 2017 7:38 pm

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.
User avatar
T4r4ntul4
 
Posts: 117
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands

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

by T4r4ntul4 Wed Dec 06, 2017 9:29 pm

I tried already a ExportFile() on android but nothing happens.
User avatar
T4r4ntul4
 
Posts: 117
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands

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

by T4r4ntul4 Tue Dec 12, 2017 1:06 am

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.
User avatar
T4r4ntul4
 
Posts: 117
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands

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

by T4r4ntul4 Wed Dec 20, 2017 9:43 pm

T4r4ntul4 wrote:Can someone test this out? maybe its just me, but nothing happens with that in android.


*bump*
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 3 guests