What are the alternate ways to avoid database call in android app? - android

Well, I have uploaded an android application on Google play store which shows live channel of my country.
I just want to avoid Database call for fetching URLs for live channel. Now alternate in my mind is that upload an XML file so that android app reads URLs from that XML and if URLs are changed later, i can upload the new XML to Google play store again ?
Now how easy is it to upload to Google Play Store, will it be automatic update for users?
What are other alternatives for fetching Streaming URL from Database or XML ?

It's obvious, that you shouldn't hardcode the list of channels inside the APK (by putting it inside the XML or DB with the assets), nobody wants to update the app just because this list was changed. The easiest way is to put XML file on some server (you may want to take a look on Amazon Web Services, they have great solution for keeping static content) and pull it either on the first run or on demand. Also you may want to use GCM to send either the message that list was updated or, if the size of the list is not very big, you can send the list itself via this service.

You want to persist some information from server into your device:
Database
SharedPreferences
File ( which could be XML or any other format like JSON, even you can save one file per
channel with that channel name to avoid parsing, I suggest json format)

Related

How can I regularly update a database of content on an Android app?

So the app is for a Parrot Rescue. It will contain profiles for each of the birds that we currently have for adoption. So a picture of the bird, and then basic info about the bird. It needs to be regularly updated as the birds are adopted out and new ones come in. What route should I go? My main concern is that I want it to be relatively easy to update so that some of the less technically inclined could use it, as I won't always be available to help them.
Instead of loading a new version of the application every time, you should implement a database on a parrot information server. Then the application (the client) will ask the server to receive parrot information.
Just implement a mySQL database and a PHP page that returns the information in JSON format. Then through the application you will make a request to the server using the volley library or okHTTP and enter the information into a list.
As there are also pictures, use the glide library to download the images.
Also remember to upload small images to the server.
This way the app is always up to date
The easiest way is to update the app on the play store with the newest db, and let auto-update update the app with the new db.
Next easiest is to have a nightly (or whatever frequency) service download a new db and replace the old one from your servers
If you want it to be as easy as possible to update for everyone I would recommend a little app that has two main activities. One for displaying the entries of the database (and maybe also giving the ability to delete the entry) and another with a template to fill with all information and the image.
Then like Raffaele D'Arco explained use a little server. You could also delay the updates to be in a 5 minute routine or the like so that you put as little stress as possible on the server.
There are multiple good ways to update the interface without updating the app constantly.
Use a database which the app will download after a fixed amount of time which will be located on the server.
Secondly, if you have a website you can convert the web pages to XML or JSON or something like that and can update the app UI as per the data downloaded from the website.
I would recommend the second option as it is quite easy than the first one...

AWS - I need to download a file from Amazon S3 into Android APP and the URL have to be hidden

I have to download a file from Amazon S3 to Android APP via Servlet and I have to hide the URL.
Is there a solution to download a file without Android App know the path?
THANKS :)
In this case you need a special layer - so called "API" displayed as Servlet on the picture. Your app passes some param like id of a picture to an API method and API returns a picture in response. Its up to API how it will dl the image from AWS but the app will never know the real url. API is a web-service, a kind of web-site which could be seen only programmatically using HTTP-requests and is a job for web-developers.
I'm not much of a web developer so I can't explain how to develop it using ElasticBeanstalk or anything else. However the main idea is that you have to assign some unique id to every file you upload to amazon. Every unique id must be related (correspond) to a particular file's url. These relations must be known to your API/server/backend only (for instance - url "http:/amazon.com/file01" will be stored as a file with id 1 and so on). Your android app should know only the id of a file (for instance - app requests a list of files from your API and gets a JSON array of available files like "{files:[{id:1,name:"file01"},{id:2,name:"file02"},{id:3,name:"file03"}...]}). So when app requests a file it "says" to API only the id (1 or 2 or 3 showing to user only a file name), the server then looks for an url of that file matching given id, downloads it and sends it to your app or creates a buffer stream so server sends received data from amazon to app and app "thinks" that file comes from your API/server (but it will be downloaded from amazon in real). Your API/server should be something like a proxy server. Also you could use FireBase Real DataBase for your needs, like to store id<->url relations there.

How do you save a file to a Firebase Hosting folder location for images through android?

I'm really new to Firebase and am studying how to implement it right now. I was thinking that it has functions similar to Parse where a ParseFile object can be created that holds the file and then has functions to upload it something like the following :
ParseFile parseFile = new ParseFile(file);
parseFile.saveInBackground();
If you have suggestions and/or working solutions do post them as they will be exceptionally useful.
I am also studying about RetroFit as it has a great way of sending MultiPartPost requests and if ever could be tied up with Firebase I just can't find the connection yet.
Thanks in advance!
Firebase Hosting is a service for hosting static assets, typically the HTML/CSS/images of a web site. You cannot programmatically add files to Firebase Hosting.
The Firebase Database allows you to store JSON data. While binary data is not a type that is supported in JSON, it is possible to encode the binary data in say base64 and thus store the image in a (large) string. See Can I store image files in firebase using Java API? Note that while this is possible, it is not recommended for anything but small images or as a curiosity to see that it can be done.
Your best option is typically to store the images on a 3rd party image storage service.

should I save user information in local database

I newbie to android programming and I have question which might sound silly.
I am writing app for a shopping store, which communicate with store's website
Every user must sign in to use the app.
In sign-in process, I save information like user name, address to send products and phone number in website's database.
I have 2 questions:
should I also save user information in local database(sqlite), so in case user would like to change stuff, I won't need to fetch it from web server?(or fetching it every time is better approach??)
The app, display list(picture+description) of products the user can buy(total 12 products).
the list can change every 2 weeks or month. should I save the images locally and have an AsyncTask to check if something changed and only then to download the delta, or should I download them every time.
Thanks in advance
Android provides support for user accounts so it's hard to say whether you can use that or whether you need to implement a custom solution without more details. Have a look here for some information on implementing authentication accounts
As for question 2, I would store the images locally as you say there are only 12. You could then have the server notify the mobile app (check out GCM) when there is an image update to pull from the server. You can also have a look at the Volley library which will assist you in retrieving and displaying images from a web server.
you can store any information in sqlite and use some cache(private/public) to store images for first time store images in cache and from second time onwards load images from that cache use volley library for server calls and image cache
http://developer.android.com/training/volley/index.html
for question two: no you don't need to save the pictures locally to keep your app using the minimum storage space.

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