I've done a small school project to manage a library with several books, using SQLite and android 2.2. Later on, they asked me to create a back office system, which I wasn't ready for. So I'm trying to achieve a simple backup system that connects to the internet.
I would like directions or hints to:
Get the project database from data/data/package_name/databases/school
Send it to a online repository, could be just a ftp connection to upload school_%date% and latest.db (same contents)
and to restore:
Download latest file from server, something like http://www.site.com/school/latest.db
Replace data/data/package_name/databases/school with the downloaded latest.db
I been reading about SOA and REST approaches but I couldn't implement that on the trivial server I own... any other advices? /cheers
SOA or REST would be the most pretty way to do it. The easy way is just to get the database file and send it to you webserver. But I don't know if your app has enough privileges to restore the database while running.
You could use the sqlite3 commandline tool to dump an sql file, see here and send it to your webserver. Restoring would be something the same, but then you have to delete your tables first, then restore the database with the retrieved data.
Maybe it would be nice to have some version dependency management like sending your app version with the backup. This way you can administer whether a database file is compatible or not.
Related
New to Android app building. I built our company website using php/mysql and my boss had an android app built previously with, I assume SQLlite, or something. Anyway, he wants me to change the database that it's currently linked with to our mysql db. For the life of me I cannot find anything even resembling a connection string or a query in the file system? In my attached screenshot where would I find this information? Or is it not held in this tree at all?
I would assume the data/model folders, but I've searched every single file in those folders. I really need some help.
SQLite is a local db. There would be no connection string, its literally accessed as part of your process.
You should NOT directly connect to a remote db. Doing so is completely insecure, as it would be putting the password for your db into the app. You need to run a web service, and hit that to get your data. The web service then connects to the db.
You should also probably figure out what the actual project is. With SQLite, you would work offline, based off a copy of the data stored locally. With a remote db, offline use is impossible. Being told to replace SQLite with a remote db and your level of understanding of that in this question shows that one or both of you don't understand what the scope of that change is, and you should make sure you're on the same page and what the best way to achieve the actual goal of your project is.
I started developing an app that uses sqlite that is to be installed on multiple devices and any updates done on sqlite database from any device are to be reflected in other devices as well. I have researched a little and found that Sqlite DB is local to a device and changes done in one device are not reflected in others and for that I have to use external server. Is there any way around it?
Is it optimal to directly store data in external server or use sqlite and sync it regularly with external database?
Thanks in advance
As far as I know, there isn't a way without an external database. I would recommend you to sync it regularly with an external database.
Checkout this question for more information how to do that:
How to sync SQLite database on Android phone with MySQL database on server?
Answer of Andrew White
Create a webservice (REST is probably best) and serialize your SQLite/MySQL data and PUT/POST/GET it to/from your web service. This will give you a nice layer of abstraction in case you decide to switch from MySQL to something else server side.
You will achieve your goal using external server. It's not necessary to create your own server, just use data store services like Parse. For more look here.
You can use data directly from external server or cache them on your device first (sqlite, prefs, json etc.) – it's up to you.
my application needs to store data locally on sqlite DB and user can upload data on server once the internet connection is available.
I assume I need to do some DB replication, how to accomplish that?
Is there any android built in facility?
Or I need to use some third party tool for that?
I read many answers on this but I am still not clear about it, I will use KSOAP2 web service for communicating with server.
Using KSOAP2 how can I Sync my sqlite data on SQL Server?
below are few links I read.
https://stackoverflow.com/questions/18207021/opensource-replication-tool-for-sqlite
Regarding sqlite replication
Does SQLite support replication?
Thanks in advance.
You shouldn't use dumps to copy the whole database back and forth. Android is running on mobile devices and datatransfer is likely to cost money or to be limited by speed or volumne or other means.
Therefore you should build your own webserver and upload/download only the changed entries. This means you will probably have to implement your own replication-logic, since I don't know any tools for that.
For example you can send a timestamp and the server replies with a set of changed data.
I'd recommend building a Restful-Webservice and using HttpUrlConnection to build POST, PUT, GET and DELETE requests.
GreenDao proposes a project for client/server-synchronization. But there is no estimation on when it will be available. If you do something yourself, you could try doing it as greendao-feature. A lot of people will thank you for that (myself included :D).
You can also have a look at symmetricDS, which should work on android.
I am trying to develop a real-time Android application where all contents are stored in server. So, they are available whenever a connection to Internet is available. Also, the application provides communication between users and conversations are stored in the server as well. Nothing is locally stored.
However, I am still cannot decide which database type I can use. I intended to use SQLite but I am not sure if I can really use it or not.
Could you please guide me to the proper database type to my application.
Appreciate your time and efforts.
As its upto you which database you use.
you may Install Lamp (For Linux) or WAMP(for window) . This is a nice database tool and very easy to handle and easy linked with PHP for various database function
I recently developed something similar to what you are talking about and here is what I would suggest you to go for.
Use SQL server to manage the data on your desktop and create a web-service in .Net on Visual Studio.
(Note that as others have already mentioned, it really does not matter what is the database you are using in your server end, because eventually the data is going to come to the Android application from the server in form of either xml or json in the web-service., regardless of what database you are using. So it is totally your wish which database you want to use.)
Then connect to the web-service in your application and set/get data from the remote Database, using SOAP.
Link on how to make a web-service in .NET (does not include the implementation in Android).
Links on how to connect your service with Android : this, this and this.
I have an application that creates an SQLite database and saves
information to it over the course of a day. At the end of the day i
want to export this database to a web server.
Could anyone point me in the right direction for this?
Should I use httppost or put. I have researched this myself online but
there seems to be so many different ways to explore. The server side
does not exist yet either. I have access to an apache server so i am
hoping to use that.
Could anyone advise me the best/most simple way to do this?
Thanks guys,
Just wanted to let you know that i used the intent provided by the andFTP app in the end. Its very simple to use and details can be found at: http://www.lysesoft.com/support/forums/viewtopic.php?f=5&t=158
Couple of ways ...
you can ftp up the db each day
you can export the data to a csv file and post it to the server; once there you can then import it into the db on the web server
Is it for backup purposes? Or do you require a number of dbs on the web server?
Do you want this to be an automatic or manual transfer? SQLite data is just a file, so (from the SQLite site)... "If SQLite can read the disk file then it can read anything in the database. If the disk file and its directory are writable, then SQLite can change anything in the database. Database files can easily be copied onto a USB memory stick or emailed for sharing." So (provided everything your app needs is set up on the server) just move the file to the server.