Android, NullPointerException on method with SQLite command in Service -


There is only one job, why are the commands in my SQLite methods, when IAM is calling it from service to me writing a nullpointerexception ? ... when I try to use toast, it works perfectly, but when I use mDbHelper.open/naplnSviatky/close, my app will crash.

There are only query commands in those methods, and the activities and pieces work well.

Here my service

 < Code> public class enhances SviatokFullFillService service {string user name; Private database access MDB Helper; @Ivarried Public Ibner on Bint (Intent Intent) {// TODO Auto-generated method stub returns empty; } @ Override Public Wide Onstart (Artist Incent, IntstartID) {// Todo Auto-Generated Method Stub, Shared Presentations Shared Preferences = PreferenceManager.getDefaultSharedPreferences (this); Username = Shared PuffmastString ("pref ezmman", "knol"); //Toast.makeText (this, user name, toast.lNGTH_SHORT). Show (); MDbHelper.open (); MDbHelper.naplnSviatky (username); MDbHelper.close (); }}   

This is my logkat

  04-22 14: 16: 43.890: E / endocrinetime (6560): FATAL Exception: Main 04-22 14: 16: 43.890: E / Android Rendime (6560): java.lang.RuntimeException: Starting from {cmp} sk.tomino.studentDiary / service sk.tomino.studentDiary.SviatokFullFirstService@410f1188 Unable. SviatokFullFillService}: java.lang.NullPointerException 04-22 14: 16: 43.890: E / Android Time (6560): Android. App Activitatand Handlesevires (ActivityTrad.Java 295) 04-22 14: 16: 43.890: E / Android Random (6560): Android. App ActiveTrade.Access $ 1900 (activityTrad.Java 151) 04-22 14: 16: 43.890: E / AndroidMenium (6560): Android. App ActiveWiththreadFreudhed $ HHollamsme (activityTrad.java: 1442) 04-22 14: 16: 43.890: E / Android Random (6560): Android. On. Handler Dispatchmail (Handler. 99) 04-22 14: 16: 43.890: E / Android Time (6560): At android.os.Looper.loop (Looper.java:155) 04-22 14: 16: 43.890: E / Andromaretime (6560): Android.AP.ActivateTrade.Mine (Activity Thread.java:5520) 04-22 14: 16: 43.890: E / AndroidTime (6560): at java.lang.reflect.Method.invokeNative (Basic Method ) 04-22 14: 16: 43.890: E / Andorrentime (6560): at java.lang.reflect.Method.invoke (Method.java: 1111) 04-22 14: 16: 43.890: E / Androindertime (6560): com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (Zygoteinit.java 299) 04-22 14: 16: 43.890: E / Andrideranta M (6560): at com.android.internal.os.ZygoteInit.main (Zygoteinit.Java: 796) 04-22 14: 16: 43.890: E / AndroidRuntime (6560): On Dalvik.system.NativeStart.main (Original Method) 04-22 14: 16: 43.890: E / Android Time (6560): Due to: java.lang.NullPointerException 04-22 14:16: 43.890: E / Android Random (6560): sk.tomino.studentDiary.SviatokFullFillService On .onStart (SviatokFullFiltService.java.30) 04-22 14: 16: 43.890: E / Android Time (6560): Android.app Service. OnOnStart Commands (Service.java:450) 04-22 14: 16: 43.890: E / Android Random (6560): Android. App ActiveTrade HandleSwires (ActivityTrad.JewA 2916) 04-22 14: 16: 43.890: E / AndroidRuntime (6560): ... 10 more    

You have declared the variable private database access MDB helper; at the class level but when you are using it in the onStart () method, then you have not started it, so it is throwing NullPointerException < / P>

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -