質問

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top