I am interested what approach to choose in situation if you have a client/server application in which you have some categories (just a type name - like coffee shop, restaurant, etc. and an icon for it), that you may want to expand in future.
One way to do it, as I see it know, is to have a string list resource (xml) and appropriate icons on the client side (concretely Android client), and when you want to add new categories, you will have to build new version and deploy it (if I'm not wrong and it all gets to binary for when compiled).
The other way is to have the type list on the server (let's say as a simple entity with type and icon), and that you're client fetches for it whenever is needed, per example, first fetch all the category names, and then the appropriate icon for selected.
So I'm interested in what is better in a situation like this?
This is ultimately called Syncing functionality. It depends on the requirement and situations.
There are actually 3 ways to implement such functionality:
Put all the required things inside the app and deploy onto the play store.
Put static things inside the app(client) and dynamic changed values on the server.
Put everything on server and sync into client as and when required.
Way 1:
In this way, you need to put everything into the app. Advantages of doing it are you would not have to depend on server and it loads faster. Disadvantage of doing is you would have to deploy app as and when data changes, even if you do a change in single value.
Way 2:
In this way, you can keep static things like company logo, company banners and all such values which are usually don't change frequently. And you can store rest of the values which you think changes frequently like employee list/details.
So if there is new data available, client needs to be notified so that it can sync latest data into the local database.
Advantage of Way 2 is you wouldn't have to load static things again.
Way 3:
In this way, everything is supposed to be on server, client has to sync data on first launch and then whenever new data is available.
Advantage of way 3 is you don't need to deploy app if any change in data values. But as this is depend highly on network connectivity/server, developer has to implement all the corner cases to avoid sync/data loss.
Related
I have a situation where admin has defined both English and Spanish Language at the admin panel. Right now, Whatever the changes he made in admin panel, it is reflecting on the website.
My question that when we have different platforms like Android and iOS, Whatever the changes he made in the Admin panel I want it to reflect in the Android as well. As of now, I have defined both language information in Strings.xml.
I do not think calling server each time for the Labels is a good idea. If i do, it might slow down the app.
In detail, i have a validation message like "Please Enter User Name". And the admin changed the label in the back-end and made it Enter User Name. Each time calling server to get the information is bad idea. I would like to save the information or data for certain periods. say 2 hours or 24 hours.
What is the best way to achieve this?
In my opinion the best solution is to keep it in sqlite. You should check version of strings by calling your API when i.e. application is starting and then update its if necessary.
Unfortunatell queries SQLITE every time when user open new activity/fragment might also slow down your app. In my opinion you should keep your map of string in Application Class or in Object (if you use kotlin) - query your sqlite after checking version of your string or when app is starting if API is unavailable.
I am creating an android app that can be used by common users and also admin.
Suppose, if admin adds a new place name, that name should be added to database and when common user uses the app, he should be able to see the place name that is added.
I used MySqlLite database. But the problem is that if the app is uninstalled all data is lost. So I want some persistent data storage in which all the places that are added by admin are saved permanently.
Regards,
Sindhu
With the data being needed across multiple devices, your only option is to create/use a backend API.
Parse would have been a good choice but since that is getting shut down soon then it wouldn't be wise to use that.
Take a look at these alternatives here
You could also write one yourself, but unless you have some experience in that sort of thing then it will take some time to learn.
I have a messenger app that makes GET /conversations requests to populate a list of the conversations of the user.
The next step is to make it "listen" for updates so that it marks conversations that have been updated and add conversations that have been created.
Should I use the same /conversations resource to get the updates or should I rather have a separate resource for that? Perhaps, something like /conversationUpdates.
It depends on whether you want to follow RESTful conventions. Many client side libraries such as backbone and extjs have fairly deep support for declaring a resource with a URI and then using the different HTTP methods (GET, POST, DELETE, etc.) against it. This might sometimes lessen the work clients need to do and folks will be grateful.
Following the convention will also make your api less surprising. There are undoubtedly other conventions for API's and not every domain space is well modeled with REST.
Rereading your post, I see you want to have an api that that just gets new posts. What constitutes new? New since the last time the client called the end point? In such instances an api might accept a parameter like the last identifier that had been received (if you are using something like a auto increment field, or a mongodb id). In that case you would just use the /conversations endpoint, with an extra parameter.
Firstly, I'd stick here with the GET method, since this is exactly the point: getting data.
As for the resource name, I'd go with the same, specifying it further in the query, something like /conversations?state=new. My point here is that the resource itself is still the same but you only want a subset of it.
However, if you plan on updating other things than conversations, you can use /updates/conversations since in this case, an update can be considered as a resource, itself composed of, among other things, conversations.
The situation: I have many real life locations with specific information associated with them, and updated frequently. I am unsure of how to store this information for use in an android application.
My original thought was storing the data on some server/cloud source/database, reading from the server from each Activity in the app to make sure the info is up to date, and update the server with any changes that may or may not have been made.
For example: there are 200 people inside the library, one person leaves.
So we would read the number of people from the server, display this on the app, person leaves, subtract one, send the new number back to the server.
Would this be an incorrect approach? I'm fairly new to Android in general, and I really have no experience on how to approach this type of situation, what services to use, etc.
I would look into using Parse, its a pretty sweet way to power the backend, and their website is very detailed in explaining how to use it.
I currently have several fragment tabs , each with a feed of user statuses, being I have about a 100 other users posting from their accounts there is constantly new data every few minutes. currently the users only choice is to switch fragments back and fourth to get the entire fragment to reload which sends another http request and returns the new data as well as all the old data the user already had. it just doesnt seem efficient, know there has to be a better way. Can someone give me a overview of the most efficient way to keep this data fresh without having the user switch tabs back and fourth?
Is this where using sqlite and/or services comes into play?
Though some developers and designers argue between if content should be refreshed automatically of not, I argue content like streams shouldn't be refreshed automatically unless you are expecting very less incoming data.
I have used twitter4j to stream tweets and refresh automatically in one of my test app, twitter4j has a listener that lets you know when new tweets are received. First I pushed data into ListView as soon as new feeds were received and it was kind of flashy but, efficient. Then I queued up data until it reached certain threshold and pushed data into ListView, it was bit better. I thought it was good enough but, when I monitored my "Data Usage", i quite realized why I shouldn't refresh automatically.
Now here are some example implementation:
(Suggest) Do some type of polling or I recommend you to implement
push(like GCM) to let your client-side know that there's new content
in the server.
(Option) Use SyncAdapter with server triggered sync
(Recommend) Let user be in control, it's more than okay to use
Pull-to-Refresh pattern like Facebook or ActionBar sync button like
Google+. It will not make UserExperience any bad.
Now here's how your sample request API should be like or you can match your own config:
{
"fromIndex": 0,
"toIndex": 10
...
}
well, i'll try to give you a general overview to see if you can get it without the need of getting into deepest details, an idea it just came to my mind:
1- you need to configure your server to retrieve from an "specific" point of the content or retrieve a token that you will pass to the server (on next HttpRequest) to know from where part of the content or from where "index" start to send the content again.
2- you need to have a Listener (i dont know how you are showing your data but this is the case of a ListView) that tells you when the user is closely to get to the end of the ListView and let't say if there are already 10 elements, in element 7 the Listener should call the method to get more content from the server.
3- Yes, you need to keep the data already retrieve in SQLite temporarily, you can't use SharedPreference to keep it because it probably would be a lot of data and maintain it in memory could be a bad idea, writing a file is not an option here neither, so SQLite is your best friend in this case.
Maybe there would be more problems specifics about what you are trying to achieve but to me in a general perspective, those 3 points should at least help you in the direction to go.