I recently have gotten very interested in android development. I have this application that needs to be able to store user accounts onto a database. How do I go about making this database network accessible, so users of my application can access their account? I've been looking into this and I think that content providers are one method of solving this problem. However, I don't know anything about content providers so some clarification would be great. Anyways here are my questions straightforward:
How do I go about making a database network accessible so users of my android application can access their account?
What is a content provider and are they free?
Thanks for your time and I appreciate the help.
Good questions, but too broad and open-ended. Also, I find it hard to understand
You have an application that needs to be able to store user accounts onto a database. Where will the database be, on the web or on the device? Do you want to be able to access a web database from the device? Do you intend to store the user accounts on the device?
If you have a web-based database, you have to provide a web server to get data from the database and offer it to your Android app. There are many ways to do this.
A content provider is one of the four main building blocks of an Android app (the others being activity, service, and broadcast receiver). Content providers provide a standard interface between local data and other components, including components in other apps. A content provider can handle files, databases, and even internal data structures you build within the provider, but most content providers encapsulate an SQLite database.
In regard to transferring data between a server and the device, content providers often represent the location of the local data. Content providers don't automatically transfer data, but in conjunction with other parts of Android a content provider simplifies the process of detecting when data has changed.
To transfer data between the device and a server, you'll need to set up your server to provide database data using HTTP, learn how to connect to the HTTP server interface from Android, send requests (I suggest the REST protocol) to access the server, send REST requests to transfer data, and then store the data on the device, probably by using a content provider.
You may also need to learn how to work with user accounts in Android, using the android.accounts.Account class.
Most of these topics are described in detail at the website developer.android.com, which is Google's official Android SDK documentation.
Related
It seems when you download a new Google Suite app for iOS - whether GMail, Inbox, Calendar or whatever - they offer you to log in with your account and already present to you the account you have logged in elsewhere.
The question is both for iOS and for Android.
I know that apps can use Safari or the new Safari WebView (Chrome Tabs in Android) and a permanent cookie to share data between apps. It's a bit clunky, and can be broken by the user deleting cookies. But other than that, it works.
Google seems to be using something else. AdvertisingID? How exactly do they achieve this feat of sharing data on both operating systems?
AppGroup allows data sharing between two different apps or even app and widgets by creating one common shared path (like document directory). Data saved over there can be accessed by any app which is associated with that particular AppGroup. It is an offline data sharing between apps.
Communicating and persisting data between apps with App Groups
On Android:
They probably use Content Providers. As described in this link,
A content provider manages access to a central repository of data. A
provider is part of an Android application, which often provides its
own UI for working with the data. However, content providers are
primarily intended to be used by other applications, which access the
provider using a provider client object. Together, providers and
provider clients offer a consistent, standard interface to data that
also handles inter-process communication and secure data access.
A content provider coordinates access to the data storage layer in your application for a number of different APIs and components, these include:
Sharing access to your application data with other applications;
Sending data to a widget;
Returning custom search suggestions for your application through the
search framework;
Synchronizing application data with your server;
Loading data in your UI.
TL;DR In short, Content Provider is a layer that allows you to share your database with other apps/widgets. So Google Probably has a Content Provider in every app which shares the accounts that have been used on this app.
On iOS:
Now I'm just an Android Developer, but after a quick Google Search, I found this post which talks about UIPasteBoard:
Use the UIPasteboard class to let a user to share data from one place
to another within your app, and from your app to other apps. For
sharing data with any other app, use the systemwide general
pasteboard; for sharing data with another app from your team—that has
the same team ID as the app to share from—use named pasteboards.
I can't assure you that this is exactly the way Google does it. But If I were to implement such thing across my apps, I would use this.
I am developing an android app with Google Maps.
Basically what a I want to do is to store the location where the user clicks in a database, but I want to store this information for all users that have the app.
I already read about SQLite in Android and his stuff but seems like I only can create a local file where I can store information. I want this information to be sync everytime the app is opened. I don't know how neither where store this information online.
Do I need something like Google Cloud SQL or any other database server to achieve this?
Thanks for all.
UPDATE 09/10:54
I recently discover that MongoLab gives you a simple database to use. In every sample I see for Content Providers in Android or Sync Adapters, I never saw a single database call nor declaration anywhere.
How you can link a content provider or sync adapter to a database?
UPDATE 09/11:24
In the Xamarin docs you can learn how to create a custom Content Provider, but again ... no database is included or mentioned.
Take a look at Sync Adapters:
Synchronizing data between an Android device and web servers can make your application significantly more useful and compelling for your users. For example, transferring data to a web server makes a useful backup, and transferring data from a server makes it available to the user even when the device is offline. In some cases, users may find it easier to enter and edit their data in a web interface and then have that data available on their device, or they may want to collect data over time and then upload it to a central storage area.
I have already an location based app which functionality i want to expand:
A user can login to this App via Facebook and also other users are logged on their own Mobilephone. Both can see the location of the other.
So basically an location aware meet people APP :-)
How can I do this? Backend with PHP and mysql database?
Are there already existing solutions I can use?
Tutorials available describing this?!
the infrastructure you need is achievable in many many programming languages and many types of databases.
In the end what you need is a server running that can store the location data sent from the users. Ideally i would tell you to use webservices in order to achieve this.
Next, you will need to implement a location service app that works on the user smartphone and uses the web services to send information and get information to and from the server.
Programming languagens you can achieve this are so many. For example, in the back end you can use a mysql database with a tomcat server. if u need a front-end for the server you can use java server pages, php, whatever u feel more confortable with.
for the mobile phone there are hybrid application for different OSs. for android specifically you will use java. if u want to save some info in the phones you can use a SQLite database. this is important if you want to send data only when internet connections are available.
Those are the kind of things you have to deal with. Hope i helped you.
Good luck.
What is the equivalent of Android's content provider in iOS?
Summary:
A content provider manages access to a central repository of data. A provider is part of an Android application, which often provides its own UI for working with the data. However, content providers are primarily intended to be used by other applications, which access the provider using a provider client object. Together, providers and provider clients offer a consistent, standard interface to data that also handles inter-process communication and secure data access.
Docs:
http://developer.android.com/guide/topics/providers/content-providers.html
If I'm understanding that link correctly, there is no equivalent.
On iOS, apps can't share resources between each other in that way. For security reasons, each app has it's own data and is sandboxed from being able to access the data within another app.
The only ways you could share data between apps is to have some network sync process between your apps, or possibly use UIPasteBoard but that's cumbersome. You can also pass very limited data via the app URL scheme.
There's a way to share content between apps via keychain if one wanted to in iOS. I think this is the closest I can think of that is equivalent to the content provider in Android.
Good reference here: http://shaune.com.au/ios-keychain-sharing-data-between-apps/
In iOS we can share data between apps having same group id.
[iOS App Group] allows you to share data between between different processes from the same development team
[iOS App Extension] allows you to share common functional
Hi I want to sync android database with web database, my scenario is:
I want to make an android app dictionary. The dictionary words are added by web forms and the user android consume those words. In the Android application I have the historical of words that the user displayed and data of their studies, that should be synchronized online in case of change user phone or him have multiple devices.
My question is how to do that:
I need authentication or can get the User's google account to identify him?
How should I synchronize these two databases?
If I use Backup API i can get the same data in diferents devices?
I need authentication or can get the User's google account to identify him? That's your decision. You could even provide both methods. Some people don't want to share everything with Google, others don't care. If you want to create your own authenticator read the Udinic blog post about it.
How should I synchronize these two databases? You need a sync adapter in Android and a receiving service in your web application. In the Udinic blog there is also a tutorial about sync adapters. On server side you could create a REST service for example.
If I use Backup API i can get the same data in differents devices? The Backup API doesn't seem to be the right choice as it only restores data during the initial setup and I assume you want to synchronize the data all the time.