Leave DB Android created Google Play before publication. - android

I have an android project which has a local database, when the application starts it syncs with the web service, I have a JSON file containing Countries, States and Cities of Brazil that is imported into the database as the user need this information to register the address of their customers ...
I can not get this information from the Web, because the proposal of the app is to work offline, and when you have an internet connection to send data to server.
Therefore, I was wondering if there is a way to get this data previously entered in the database and not embed them in the first inicilizaĆ§Ć£o, this works, but requires a lot of processing, it takes about 5 minutes on average (this is long ) to do the import.
Any solution?
Thank you!

My previous app has the same problem like this. I give you the solution that I did:
Before release your app, you should embed the latest database (imported by json, call db1) in asset folder, then copy it into application database folder (something like /data/your.package/databases) when initializing app, it only takes some seconds. By this way, you can query data and check user login/register normally.
Whenever device comes to internet, you just download the latest json data and import it into another database file (call db2) on background.If this progress doesn't have any errors, you can replace db1 file by db2 and it can work properly.

There is no other way to do that but you can minimize your payload using gzipinputstream, big cookie model to sync to your server, fast networking library called volley etc.,

Related

Export data to preload into a Firebase instance in a mobile app

The use case is a dual platform mobile app for an event. There is a schedule with photos, links, bios of the speakers and talk descriptions. If all of the attendees happen to download and open the app at the same time and in the same place, they might not get the best experience -> the WiFi might slow the calls into the data server, calls into the FireBase server side will spike.
Is it possible to export a database from the server side and preload the event schedule data into the mobile app download? Upon launch the app can sync any last minute updates, as needed, with a connection and a short sync to Firebase.
If this type of architecture is not available, is there an alternative that the Firebase team would recommend?
There is no way within the Firebase Database API to preload data into the disk cache.
Two things I can think of (neither of them very nice):
Have the client read the JSON file from your app's resources and write it to the location. The end result of this will be that the data on the server stays unmodified. But it does result in each client writing the same data to the server, so the inverse of your original problem (and likely worse performing).
Have a wrapper around the Firebase API calls that loads from the JSON file and then have them later attach listeners after a random delay (to reduce the rush on the app).
As said, neither of them is very good. For both of them, you can download the JSON from the Firebase Database console.
In my experience the usage of conference apps is a lot lower than most developers/organizers imagine. It's also typically quite well spread out over the duration of the conference. So reducing the amount of data you load might be enough to make things work.
On android you can ship a sql database in the assets directory with the app and then reconcile it with the updates when the users open the app. The Firebase database is a json file. You could also ship that in the assets directory and then reconcile on first load.

which is best option to publish android app with local database?

I am developing an app in which i would need a local database.
So as per my knowledge there are two ways to do it:
First is to add pre filled database file in assets folder & make copy of local database from it the very first time app is started.
Second is using script to download it from Server for first time of app use?
First way have been pretty well answered by this guy Using your own sqlite database in android application
Can someone help how can i go with second way of download data from Server?
Should i use JSON/XML for getting that data from my Server?
Or should i go with first option since my app has only around 150 to 200 rows in the db file?
Go for the local db for the following reasons:
The users would have great on boarding experience as they can very quickly start seeing the utility of the app since you provide some data on first run without any delay that might be added when you fetch data from the server.
Do it for sure if the db doesn't increase the apk size significantly.
You must use php only if you need get information from the server, with php and json is better ...
http://www.vogella.com/articles/AndroidJSON/article.html
and if you only need share local information, only needs use MYsqLite ...
http://www.vogella.com/articles/AndroidSQLite/article.html

Android: Updating local database from an online database

I have an android application that works as an inventory application to different stores (You can search for any electronic device according to certain specs and find which stores sell it and their location). The application comes with a local database, this database needs to get updated through a soap service to have the latest information about the electronic devices, offers and shops. The soap service will get it's data from another database hosted on the web and that gets updated from different sources through a designated website.
The problem we are facing is that we can't figure out the way to update the local database without having the user downloading the whole "online" DB from the web every time it gets updated as that would be bandwidth consuming an the DB can get as big as few MegaBytes.
We came up with the following solutions:
Create Versioned Update Scripts that will have the SQL transactions done on the online DB, the application will download them and run them to update the Local database. The issue with this solution is that if a user doesn't update the application regularly, they will have to download alot of scripts to do the update the next time they are going to update the application, and most likely it will contain a lot of junk scripts (Items get added on an early script, then gets deleted on a later on) .
Download the online DB and replace the local one with it. As mentioned above this can be pretty annoying since the DB size might be a few Megabytes.
Can someone help me with this issue?
TYI
Your best bet would be Google Cloud Messaging for Android (GCM)
http://developer.android.com/guide/google/gcm/index.html
It doesnt get any better than this. This video should get you up and running in no time dude.
http://www.youtube.com/watch?v=51F5LWzJqjg

approach for synching android app database with server db?

I'm developing an Android app as a "proof of concept" for our company. If they like it and think it's worth investing, then we'll move on to bigger things. I'm trying to figure out the best/most practical approach for this.....the basics of the app will connect to our DB and display information regarding a specific customer. For now, let's say we will only pull data from 3-4 tables (but there could be 10+ in the future). If the app doesn't have an internet connection then it should use the local DB. What is the best approach for this? Here's what I was thinking and would like some input/suggestions if possible:
1.) app runs checks internet connection. If exists, check db version (how, through a web service?)..if server db is newer, get latest data. If no internet, use local db.
2.) app parses data and displays it.
If this is correct, then there could be no modifications to the web service that would add fields to a result without changing the app as well. Is there a way for an app to parse fields regardless of how many fields there are?
I've read and walked through the tutorial on google with databases and such (Notepad tutorial) but it seems like the column names are all hard-coded in the parsing class, which I was hoping to avoid.
Sorry if this is confusing but I know I need my app to use a local db to read data, I also know that the app must get data from the server when it can (via onCreate or a refresh button) and copy it locally....Copying it locally is the part I'm having trouble understanding I guess....is there no way of saying "go out and get this result and display it", knowing that those results could mean 5 fields the first time or 1 the next.
Any help/guidance is greatly appreciated!
You probably want to use a SQLLite DB to store your data locally, a ContentProvider to provide CRUD access to the db, and a SyncAdapter to sync with your server when possible. The Sync Adapter also writes to the DB via the ContentProvider. See the SampleSyncAdapter sample in the SDK for an example of how this works. You will be implementing your own ContentProvider, but the sample just uses Android's supplied Contacts ContentProvider.
http://developer.android.com/resources/samples/SampleSyncAdapter/index.html

Android sync without login

I'm trying to add a synchronization function to my app which will work like this :
I want it to be login free, so no new account will be needed.
The data will be assigned to the user's google account on which he's logged in.
On server side, there will be a mySQL database wich will hold the user's data.
I didn't find a useful tutorial. http://code.google.com/p/openmobster/wiki/AndroidSyncApp This one uses some weird servlet or whatever, and the official google tut is very briefly explained.
Could anyone help me ?
I could imagine synchronization through xml - like implementing a function that would create an xml file from my database, upload it to the server and parse it/put it my online database.
This would be useful, if I only wanted to be able to modify data on one end - the phone - but then it wouldn't be called syncing, rather backup.
Or maybe I could request a similar xml file from the server. I think it should be possible to send some kind of query from the device to the server which would call a function that creates an xml file from database entries and then download the created file, parse it, compare with the device's database and update the database if some file was updated (it's 'last edited' time was changed).
So on each sync cycle I would first get the server-side xml file, update the local DB, then create the xml file from local DB, send it to the server and update the online DB. Only files with newer "last edited" time would be updated.
What do you think ?
Just for the communication between App and Server, you could use XML or JSON. But if you also want to write to the Database and/or transfer files to/from the Server, you're going to need something with Sockets.
I have the same issue.
In my case I have two separate parts to the app, one is a genreal information feed, the other is secured user data.
I need them both to sync, but the general feed needs to sync even if the user has not logged in.
There are two things I'm going to try:
1) Add the sync but don't ask the AccountManager for the token. This might skip the whole login prompt.
2) USe a separate service that can wake up and sync the general data. (I suspect this is the correct way to go).

Categories

Resources