Storing Local Data on Android Phone and then uploading with Google Spreadsheets - android

I am developing an android application for rural villages where 3g access is not always present. The application will be based out of a Google Spreadsheet. It should be such that if there is no internet access, new data entered will be stored on a local file and when there is internet connection, it will automatically sync with the online file. What is the method to properly proceed with this? Can i store a local excel file or something similar and then sync that file with the online google spreadsheets? Are they even compatible?
Sorry for the many questions but any help will be great!

The usual way to store structured data on Android is to use an sqlite database. Save your data , then just copy it to the Google spreadsheet using the API. If you want to get fancy, you can write a sync adapter and let the OS schedule it for you. Not sure how well that is going to work if connections are unreliable though.
MyTracks is an open source that does something similar, you can use it as a reference: http://code.google.com/p/mytracks/

Related

Where to find database connections in an Android App

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.

How to make changes to sqlite database for app that is installed in multiple devices?

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.

Corona; How do I create a database so that users can access it online using their android phones?

I am trying to make an game using corona sdk where a user can see what items he has and how much he has left. Its abit like a inventory management app. How do i go about doing this? I have no idea what to do and where to start. Currently what I found online is this:
-- open "data.db". If the file doesn't exist, it will be created
local path = system.pathForFile( "data.db", system.DocumentsDirectory )
local db = sqlite3.open( path )
This actually creates a local database which I don't want. I'm guessing instead of "system.DocumentsDirectory" I should put in something else? I referred online at corona labs (http://coronalabs.com/blog/2012/04/03/tutorial-database-access-in-corona/) but nothing really gave me what I needed.
Any help on this is welcomed. Thanks.
EDIT: I'm using SQLite if that's important. Also if anyone is not sure what I'm trying to ask, basically I'm trying to have a database stored online so that i can access it using my android device. How do i do that and what tools do I need?
You would have to make a REST API to manage online database and then use the HTTP requests to create, remove, update or delete records.
I would suggest to work on HTTP server which would provide you endpoints to interact with your database records then use Corona's network requests to communicate with the server. You can use the JSON format to easily exchange data over HTTP.
You can read more about network requests here.
If you want to know about REST APIs or database endpoints you can start reading about it here.
You can read about using JSON in Corona SDK here.

How to communicate with xml file in android

My app should have capability to work online and offline.
When I have internet, I will connect to tomcat server and fetching the json object and displaying the details.
But if I don't have internet access, I want my app to work. So my idea was to store the data in xml files in mobile at some folder when my last communication done with server. Is it possible?
If so how can I do it.. Can anybody help me ???
You can store the data in your internal memory and every time you hit the server delete the old contents.
Maybe you can use Preferences or a database

Backup/Restore database file from device to website?

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.

Categories

Resources