나는 다음과 같은 documenation 당신이 익숙해 추천 할 것입니다 :
정보 제공자 :
http://developer.android.com/guide/topics/providers/content-providers.html
을 기본적으로 당신이 컨텐트 리졸버에 "URL"은 (아마도 당신이 somethign 같은 일을하고 있다는 통과 할 때 이) :
// Queries the user dictionary and returns results
mCursor = getContentResolver().query(
UserDictionary.Words.CONTENT_URI, // The content URI of the words table
mProjection, // The columns to return for each row
mSelectionClause // Selection criteria
mSelectionArgs, // Selection criteria
mSortOrder); // The sort order for the returned rows
당신은 안드로이드가 ContentProvider로 그 URL을 해결하도록 요청할 것입니다. h는 해당 URL을 처리하도록 설정됩니다. URL은 "가상"이 아닙니다. 로컬 객체와 프로세스는 ContentProvider 메커니즘을 사용하여 다른 응용 프로그램에서 데이터를 저장하고 사용할 수있게 해주는 응용 프로그램에 의해 정의되고 존재하는 로컬 객체 및 프로세스입니다.
URL의 목표 (이 경우 URI로 변환 됨)는 원하는 ContentProvider와 원하는 내용을 지정하는 것입니다.
이 코드는 당신의 튜토리얼입니다 :
ContentProviders은 일반적으로
편집이 .. 데이터베이스를 관리하는 등 액세스 위반을 최소화하면서 다른 응용 프로그램에서 사용할 수있는 정보를 확인하려면 응용 프로그램에서 사용된다. 추가 의견을 참조하십시오 코멘트에
/// this url points to the content provider.
//The content provider uses it to
///reference a specific database which it has knowledge of
//This URI doesn't represent an
//actual FILE on your system, rather it represents a way for you to tell the content //provider what DATABASE to access and what you want from it.
String URL = "content://com.example.provider.College/students";
// This line converts yoru "URL" into a URI
Uri students = Uri.parse(URL);
/// This call returns a Cursor - a cursor is a object type which contains the results of your QUERY in an order manner. IN this case it is a set of rows, each of which has a number of columns coresponding to your query and database, which can be iterated over to pull information from the DB..
/// managedQuery takes, as an argument, the URI conversion of the URL - this is
// where you are actually calling to the contentprovider, asking it to do a query on the
// databse for some information
Cursor c = managedQuery(students, null, null, null, "name");
// This line moves to the first ROW in the cursor
if (c.moveToFirst()) {
// this does somethign as long as the while loop conditional is true.
do{
// This line creates a pop up toast message with the information stored in the columns of the row you the cursor is currently on.
Toast.makeText(this,
c.getString(c.getColumnIndex(StudentsProvider._ID)) +
", " + c.getString(c.getColumnIndex(StudentsProvider.NAME)) +
", " + c.getString(c.getColumnIndex(StudentsProvider.GRADE)),
Toast.LENGTH_SHORT).show();
} while (c.moveToNext());
}
귀하의 질문이었다 :
는 "나는이 필요로하는 모든이 파일의 예입니다 : 문자열 URL ="내용 : //com.example.provider.College/students ";, 데이터 모양은 무엇입니까?"
이 답변은 사용자가 휴대 전화에 Sqlite 데이터베이스를 가지고 있다는 것입니다. 일반적으로 응용 프로그램 및/또는 컨텐트 공급자에 의해 생성됩니다 (이 경우에는 확실히). 액세스. 또한 콘텐츠 확인자가이 URI와 다른 정보를 받아들이고 커서를 돌려 줄 것이라고 알고 있습니다.
이 질문은 커서가 무엇인지 설명합니다.
use of cursor in android
자습서를 읽는다면 충분히이 코드 ::
public class StudentsProvider extends ContentProvider {
static final String PROVIDER_NAME = "com.example.provider.College";
static final String URL = "content://" + PROVIDER_NAME + "/students";
static final Uri CONTENT_URI = Uri.parse(URL);
static final String _ID = "_id";
static final String NAME = "name";
static final String GRADE = "grade";
또한 발견 할 것이다, 당신의 튜토리얼의 매니페스트에서 찾을 수 있습니다 :입니다
<provider android:name="StudentsProvider"
android:authorities="com.example.provider.College">
</provider>
을 해당 URI에 대한 ContentProvider의 등록.
귀하의 URL과 "PROVIDER_NAME"및 "URL"의 유사점이 있습니다. 이것은 ContentProvider가이 값을 사용하여 안드로이드 시스템에 대한이 partiuclar URI의 리졸버로 자신을 식별하기 때문입니다.
자습서에 설명 된대로 파일을 만들어 샘플 앱을 작동 시키면 더 명확하게 이해할 수 있습니다.
URL이 맞으면 브라우저에서 열리지 않습니다. 나는 네가 혼란 스럽다고 생각한다. – Raghunandan
위 URL은 WorldWide 웹에서 사용하지 않는 콘텐츠 제공 업체 (Android LOCAL) 용 URL입니다. 서버에서 코드를로드/풀하려는 경우 네트워킹 솔루션이 필요합니다. ContentProviders는 그렇지 않습니다. –
이 질문에 URI와 URL이 혼재되어 있다고 생각합니다. – Magnus