3

In my application I want to send data stored in the local sqlite database to server's sqlserver database. Is there any utility for android to directly send the .db file and read the content in the server. Writing multiple insert statements will make code very lengthy and will cause in the primary key violation. Please help.

denvercoder9
  • 2,898
  • 3
  • 26
  • 39
Neetesh
  • 103
  • 1
  • 2
  • 4

1 Answers1

5

When you create the database you are specifying the database name (for instance products.db). If your application package name is com.example.yourapplicationpackage, you can access the file using the path: /data/data/com.example.yourapplicationpackage/databases/products.db

Then you can send that file just like any other file to your server (use a POST request). On the server side, you need classes to read a SQLite 3 database file, this should not be hard to find.

Vincent Mimoun-Prat
  • 27,630
  • 15
  • 77
  • 123
  • Great comment. A follow up question: can you use this for backup/restore through the BackupAgent android facility? I'm trying to find the easiest way to backup/restore. The only problem I see with this is lock conditions. Ideas? – llappall Jan 28 '12 at 18:10
  • 1
    But you must be root, right? Is there a way to do it programmatically whithout having to be root? – Mickäel A. Apr 23 '14 at 19:08
  • @Flawyte afaik u can use external memory if the device supports – Rapunzo May 23 '16 at 12:10