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

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

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

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

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

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

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

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

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

Post by Fred »

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

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

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

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

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

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

Post by T4r4ntul4 »

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

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

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

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

Post by T4r4ntul4 »

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