我想实现一个SyncAdapter因为我想与服务器同步内容。看来,要做到这一点,你需要注册为您在SyncAdapter XML属性文件中指定的权威ContentProvider的。
I want to implement a SyncAdapter for a content I want to synchronize with a server. It seems that to do so, you need a ContentProvider registered for the authority you specify in the SyncAdapter XML property file.
由于我不希望这些内容可以访问到手机上的其余部分,我还没有实现我自己的ContentProvider并用于个人实现存储这些内容。
As I don't want this content to be accessible to the rest of the phone, I haven't implemented my own ContentProvider and used a personal implementation to store this content.
你知道,如果有可能提供一种使用SyncAdapter的同步,而不提供ContentProvider的?
Do you know if it is possible to provide a synchronization using a SyncAdapter without providing a ContentProvider?
非常感谢你。
您总是有实施SyncAdapter时指定一个内容提供商,但是这并不是说,它实际上已经做任何事情。
You always have to specify a content provider when implementing a SyncAdapter, but that's not to say it actually has to do anything.
我已经写了创建帐户,并与整合SyncAdapters账户与同步,在Android框架不一定存储的内容在一个标准的供应商
I've written SyncAdapters that create accounts and integrate with the "Accounts & sync" framework in Android that don't necessarily store their content in a standard provider.
在你的XML / syncadapter.xml:
In your xml/syncadapter.xml:
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="com.company.app"
android:contentAuthority="com.company.content"
android:supportsUploading="false" />
在你的清单:
<provider android:name="DummyProvider"
android:authorities="com.company.content"
android:syncable="true"
android:label="DummyProvider" />
和再存在,添加一个虚拟的供应商,并没有做任何事情,除了有用DummyProvider.java:
And then add a dummy provider that doesn't do anything useful except exist, DummyProvider.java:
public class DummyProvider extends ContentProvider {
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
@Override
public String getType(Uri uri) {
return null;
}
@Override
public Uri insert(Uri uri, ContentValues values) {
return null;
}
@Override
public boolean onCreate() {
return false;
}
@Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
return null;
}
@Override
public int update(Uri uri, ContentValues values, String selection,
String[] selectionArgs) {
return 0;
}
}