mysql - Access Two Different Table Data in a Single Android Class, from Azure Mobile Service Local Database Getting Error -
1.i using 2 different azure local database tables in android application sync azure database.
2.whenever i using 2 different local database table credentials using in single class, getting null pointer exception.
error logcat:
java.util.concurrent.executionexception: com.microsoft.windowsazure.mobileservices.table.sync.localstore.mobileservicelocalstoreexception: java.lang.nullpointerexception 02-08 11:23:38.666 4742-5196/com.knowledgeflex.task w/system.err: @ com.google.common.util.concurrent.abstractfuture$sync.getvalue(abstractfuture.java:299) 02-08 11:23:38.666 4742-5196/com.knowledgeflex.task w/system.err: @ com.google.common.util.concurrent.abstractfuture$sync.get(abstractfuture.java:286) 02-08 11:23:38.666 4742-5196/com.knowledgeflex.task w/system.err: @ com.google.common.util.concurrent.abstractfuture.get(abstractfuture.java:116) 02-08 11:23:38.666 4742-5196/com.knowledgeflex.task w/system.err: @ com.knowledgeflex.task.unit_activity$6.doinbackground(unit_activity.java:1071) 02-08 11:23:38.666 4742-5196/com.knowledgeflex.task w/system.err: @ com.knowledgeflex.task.unit_activity$6.doinbackground(unit_activity.java:1058) 02-08 11:23:38.666 4742-5196/com.knowledgeflex.task w/system.err: @ android.os.asynctask$2.call(asynctask.java:288) 02-08 11:23:38.666 4742-5196/com.knowledgeflex.task w/system.err: @ java.util.concurrent.futuretask.run(futuretask.java:237) 02-08 11:23:38.686 4742-5196/com.knowledgeflex.task w/system.err: @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1112)
unitactivity.class
private mobileservicesynctable<tasktable> mtodotable; private mobileservicesynctable<taskunitmanagementtable>mtodotablemgmttable; private mobileserviceclient mclient; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.unit_activity); try { // create mobile service client instance, using provided // mobile service url , key mclient = new mobileserviceclient( "********", "************", this).withfilter(new progressfilter()); // offline sync local database table mtodotable =mclient.getsynctable("tasktable",tasktable.class); mtodotablemgmttable=mclient.getsynctable("taskunitmanagementtable",taskunitmanagementtable.class); //init local storage initlocalstore().get(); initlocalstore_1().get(); // load items mobile service // refreshitemsfromtable(); } catch (malformedurlexception e) { log.i("oncreate", "there error creating mobile service. verify url......!"); } catch (exception e) { log.i("oncreate", "exception occur......!"); } }
help me how access 2 different azure database local tables in single class in android.
i expect issue due how using initlocalstore(), in particular calling twice.
if @ code initlocalstore our quickstart serves few functions:
- creating sqlitelocalstore
- defining table on store
- initializing sync context store
you should create 1 sqlitelocalstore, define many local tables need on it, , initialize sync context. i've demonstrated code below.
mobileservicesynccontext synccontext = mclient.getsynccontext(); if (synccontext.isinitialized()) return null; sqlitelocalstore localstore = new sqlitelocalstore(mclient.getcontext(), "offlinestore", null, 1); map<string, columndatatype> tabledefinition = new hashmap<string, columndatatype>(); tabledefinition.put("id", columndatatype.string); tabledefinition.put("text", columndatatype.string); tabledefinition.put("complete", columndatatype.boolean); localstore.definetable("todoitem", tabledefinition); map<string, columndatatype> nametabledefinition = new hashmap<string, columndatatype>(); nametabledefinition.put("id", columndatatype.string); nametabledefinition.put("name", columndatatype.string); localstore.definetable("nametable", nametabledefinition); simplesynchandler handler = new simplesynchandler(); synccontext.initialize(localstore, handler).get();
Comments
Post a Comment