Suppose I have to make the following things:
An Android app that must send informations periodically to a database (without the interaction of the user)
Moreover, this android app, must provide various services to the user (user interaction)
Also, i want to provide a web interaction to the user, and for it i would like to use Vaadin
I use MySQL for the database
Is it correct to have this structure?
Android <--> PHP <--> MySQL Database (using XAMPP)
Vaadin (web side) <--> JDBC <--> MySQL Database (the same database as above)
Its not incorrect but you are creating double work. You are creating web services in PHP to service the android client call this API1 then you are creating a Vaadin based web site which also acts as an API call it API2.
Two API's in different frameworks to maintain which is just adding more maintenance and complexity. If the web site mimics the android application you will essentially be duplicating the code.
Or if you want that in pictures:
Create a web-services API that will be used by Vaadin and the Android application. This will eliminate the double work. If you create the Web-services using REST or SOAP you will be able to reuse those services across both front end application. Now when you grow the application i.e. you want to add iPhone you can simply consume the same services.
Or in pictures:
Hope that makes sense.
Related
I need to create a Rails app which in the future will need to share the same database with a native app.
As I am still quite inexperienced I would like to understand which way is the best to have the 2 app share the same database, in this case I will use postgresql.
I'm thinking of using postgrest for it but I'm unsure if there are any better/ faster ways.
which way is the best to have the 2 app share the same database
The best way is to not share database at all. Mobile app does NOT talk to database directly. Instead, it should talk to an api server, which will provide needed data and perform appropriate checks (user credentials, etc.)
The API server may be implemented as part of the same rails app or a separate app.
Another way might be to expose a read replica for your database to the mobile which can access the data directly through it via the API calls.
There are lots of options, depending on what you are trying to achieve with the web app. You can look into BAAS's such as Firebase or similar products. However, if you are already using rails, you try the new Rails 5 API mode, where all your controllers and models are preformatted to serve JSON making it slightly easier to get your API up and running for your native app.
An API (to clarify your understanding based on your comments), is a layer that will deal with creating, updating, editing, and deleting things in your database. You will have to define it using your own code (or rails generators if your app is very simple). This layer is so you can insert business logic before the database operation is performed based on the request sent from your app.
The background story: I have a nice client in a form of an android app, and now I want to create a backend that will use the Data Store service of google.
Now, I've created a simple backend module in android studio (SayHi example) which I've tested and works well.
My problem is how to proceed now. all the backend developing itself should happen in Android Studio or another environment? where do I create the backend classes and objects? how do I connect it to the data store service and perform queries?
Main question- how the backend creation process exactly goes, and once I'll connect the dots- where is the information on how to develop it (classes creation etc).
thanks!
You can do your development inside of Android Studio. Just have 2 seperate modules inside the same project; one for the android app and one for the backend.
You've integrated the sayHi example and you've said it works. Have you been able to call it from your app? If so, just look at the example, make sure you understand how it works and expand on it.
For you backend it would be best to use some sort of Service Layer - Business Layer - Data Layer design pattern. The endpoints themselves would be in the Service layer. The business layer will manipulate the inputs and outputs. And the Data Layer would be your connection to GAE. I personally use Objectify in combination with the datastore but you don't have to.
I want to build a website, where the data will be saved in a data base, logical in a sql database. Also, I want to build an android app, which will take the data from the above (sql) data base. How can I achieve it? I mean how can I manage the communication between the website and the android app. In past, I have create website with php and sql and also I have build android apps, but now I want to achieve the communication between them. Can I use parse platform?
FYI, without any server communication you can't use the website database in android application.
If you want to manage the communication between the website and the android app means you need a centralized server which having the data of your web/mobile applications. So, after that by using the web service methods (REST/SOAP) you can achieve the communication between them.
yeah unfortunately chrome won't let webapps use local storage on android. what you can do is create a local server (using org.apache.http package for example), let it run as a background android service, then have the website make requests to that url. Its considered hacky, but it would work. You can post whatever data you wanted the website to know about , and then get it from the website.
Hi guys so I am new to android development or any mobile device development.
So I am working on a project that consists of two application.
One with ASP.NET MVC4, one with Android.
what it is doing right now, Android device is accessing database server of ASP.Net application and saves data. This is able because currently, android app has database access information in the codes(db login info).
Since method above is extremely stupid I need help.
So what I am looking into is to use JSON(if possible). ASP.NET MVC4 application is already JSON ready, and i've made sandbox application that brings information from web app to android app. BUT my question here is is it possible to do same thing the other way around. Is it possible to make android application to make JSON and web application to access that application? I dont think this is possible.
So how do other REAL mobile applications save users data on their database server without including db access information within the code?
This is usually done through web api - have a look at twitters api as an example https://dev.twitter.com/docs/api/1.1
You would have to pass data to the server using the api, just as you would use an api to get data from the server.
I've built a Rails 4 web application with PostgreSQL database and hosted it on Heroku. The future plan for that database is to also be used by one Android application.
I am not completely sure how can I accomplish that. Do I need to build another REST application and host it on Heroku and somehow connect to the same database or there is another way?
How to connect with Android application to that database which is used by the web site? I know I can't connect directly.
Thank you for your guidance.
You don't need another app - just build an API for current one and then you can communicate from Android app to your web application (web app will connect to db and return data).
Have a look at Twitter API as example - you can access different resources and manage them via Twitter API
https://dev.twitter.com/docs/api/1.1
You can build something similar - create rails controllers that access your database and respond with structure you want - preferably JSON format of your models (or something custom if you need)
From Android app you can send request to your API and parse JSON responses - then process data your own way on Android app.
Don't forget about authentication between your Android app and web application - let only your Android app to use it.
I encourage you to browse internet for best practices 'How to create an API' :)