Android:Azure移动离线同步引发“异常抛出异常”

时间:2018-10-24 17:30:05

标签: android azure-mobile-services offline

我在azure移动应用程序中有一个后端。 ios版本运行良好,但是在android中我启用了离线同步,并且抛出此错误“使用null异常抛出”。我首先尝试了在线获取。每个字段都有数据。下面是我的代码。请指导我做错了什么地方。

  try {

        mClient = new MobileServiceClient(
                "https://chenabclub.azurewebsites.net",
                this).withFilter(new ProgressFilter());


        mClient.setAndroidHttpClientFactory(new OkHttpClientFactory() {
            @Override
            public OkHttpClient createOkHttpClient() {
                OkHttpClient client = new OkHttpClient();
                client.setReadTimeout(20, TimeUnit.SECONDS);
                client.setWriteTimeout(20, TimeUnit.SECONDS);
                return client;
            }
        });

        mToDoTable = mClient.getSyncTable("AppFoodMenu", AppFoodMenu.class);
        initLocalStore().get();


        refreshItemsFromTable();

    }

这是我的本地商店           SQLiteLocalStore localStore =新的SQLiteLocalStore(mClient.getContext(),“ OfflineStore”,null,1);

                Map<String, ColumnDataType> tableDefinition = new HashMap<String, ColumnDataType>();
                tableDefinition.put("id", ColumnDataType.String);
                tableDefinition.put("icode", ColumnDataType.String);
                tableDefinition.put("ides", ColumnDataType.String);
                tableDefinition.put("priceet", ColumnDataType.String);
                tableDefinition.put("priceit", ColumnDataType.String);
                tableDefinition.put("tax", ColumnDataType.String);
                tableDefinition.put("rcode", ColumnDataType.String);
                tableDefinition.put("ccode", ColumnDataType.String);
                localStore.defineTable("AppFoodMenu", tableDefinition);

                SimpleSyncHandler handler = new SimpleSyncHandler();

                syncContext.initialize(localStore, handler).get();

我的模型课是

     public class AppFoodMenu {
@com.google.gson.annotations.SerializedName("id")
private String mId;
@com.google.gson.annotations.SerializedName("itemcode")
private String ICode;
@com.google.gson.annotations.SerializedName("ides")
private String Name;
@com.google.gson.annotations.SerializedName("priceet")
private String PriceET;
@com.google.gson.annotations.SerializedName("priceit")
private String PriceIT;
@com.google.gson.annotations.SerializedName("tax")
private String Tax;
@com.google.gson.annotations.SerializedName("rcode")
private String RCode;
@com.google.gson.annotations.SerializedName("ccode")
private String CCode;
@com.google.gson.annotations.SerializedName("unit")
private String Unit;
public AppFoodMenu() {

}

0 个答案:

没有答案