Database in Android

Asked

Viewed 595 times

1

Hello! A few days ago, in a question I asked here at Stackoverflow, I said I was starting to develop for the Android platform. This week has been very productive and I already have some ideas to apply, but I have a lot of questions. I would like you to answer me.

I thought of a project that could be used both on the computer and on mobile devices. For this I will have to use webservices, correct? Could you recommend me some appropriate approach to achieve this goal?

This is related to another factor, which is about data storage. In my studies, during this week, I created some things using Sqlite. For a larger project I can use another bank?

Data modeling is also done in the way that is usually seen in desktop systems development?

I know it’s already three questions, and they may seem conceptual. But it’s just that I’m a little lost and I couldn’t find anything very relevant in the courses I’ve done in the last few days.

So. What are your considerations?

2 answers

1


If by "proper approach to achieve this goal" you mean which technology to use to make your webservices, choose the one you prefer. If you have more ease with Java, use Java, otherwise it is common to use PHP.

The bank you will use on the device is one thing (and usually only the same Sqlite is available). It has nothing to do with the bank that you will have on the server and that your webservices will access. The server uses Mysql, Postgresql, among others. Note that on the server the databases usually support competition (there are no conflicts when multiple requests are made to these databases), already in the device Sqlite this competition is not supported and you need to implement manually (if there is a chance that more than one thread from your app will try to access your device data concurrently, otherwise you don’t have to worry about it).

The recommendation is: do not access the server database directly from the device, do it through web services.

Yes, data modeling is also done in the way that is usually seen in desktop development.

  • Quite enlightening, @Piovezan. I had no idea that I would have to use a bank on the Android app and another one on the server. I thought I would make the requests directly on the server and what web services would serve for it. That is: I imagined that a web service would make sense only in cases where there is more than one application consuming the same data. Another question arose: if I will use Sqlite on mobile and another bd on the server, the web service would be to keep the synchronization of this data? Hugging, and thanks for the reply!

  • Just to make sure you understand: when you make a mobile app you will usually have more than one app accessing the same data. A webservice can be called by multiple applications and each call will access the same bank. The problem of calling the bank directly (via JDBC in the case of Android, without going through a webservice) comes from the fact of not having a stable network along which the connection with the bank will be maintained without risk of a possible fall.

  • As for your last question, not necessarily. It will depend on each type of application. Often you will want to store data locally that is not "mirrors" of server data, such as logins/passwords, user settings, etc.

  • Not forgetting that for the case of simpler data (an integer or a string, for example) Android has the feature of Shared Preferences.

  • Thank you very much for the clarifications, @Piovezan. I think your answers already establish a starting point for some studies. Thanks a lot!!!

-1

You’re going the right way.

Any kind of access to "external database" (let’s call it that), should be done via Webservices. Take a look at this article http://www.androidpro.com.br/usando-banco-de-dados-externo-no-android/.

For internal storage on Android (database) you have the Sqlite to do this. But be careful, it is a very limited and simple bench, use sparingly for your application does not get too heavy and slow.

Note: Do not save images and/or files in Sqlite, this makes the performance fall too much.

On data modeling, it is relatively equal. You need to define both on your server where your Webservice is located and on your application the modeling of your application data. Only in Sqlite take care of very complex modeling and relationship.

Abs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.