Reputation: 756
public boolean isValidPin(String pin) {
type = false;
Cursor c =db .rawQuery( "select * from"+ pinTable+" where Pin='" + pin+ "'", null);
if (c.getCount() > 0)
{
c.moveToFirst();
type = true;
}
c.close();
return type;
}
i have a button on a dialog box in android wen iclick it stops forcefully... this is the logcat error..
03-26 07:35:23.140: E/AndroidRuntime(16907): FATAL EXCEPTION: main
03-26 07:35:23.140: E/AndroidRuntime(16907): java.lang.NullPointerException
03-26 07:35:23.140: E/AndroidRuntime(16907): at com.android.lnt_form.WayDataBase.isValidPin(WayDataBase.java:147)
03-26 07:35:23.140: E/AndroidRuntime(16907): at com.android.lnt_form.LoginActivity$3.onClick(LoginActivity.java:133)
03-26 07:35:23.140: E/AndroidRuntime(16907): at android.view.View.performClick(View.java:4202)
03-26 07:35:23.140: E/AndroidRuntime(16907): at android.view.View$PerformClick.run(View.java:17340)
03-26 07:35:23.140: E/AndroidRuntime(16907): at android.os.Handler.handleCallback(Handler.java:725)
03-26 07:35:23.140: E/AndroidRuntime(16907): at android.os.Handler.dispatchMessage(Handler.java:92)
03-26 07:35:23.140: E/AndroidRuntime(16907): at android.os.Looper.loop(Looper.java:137)
03-26 07:35:23.140: E/AndroidRuntime(16907): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-26 07:35:23.140: E/AndroidRuntime(16907): at java.lang.reflect.Method.invokeNative(Native Method)
03-26 07:35:23.140: E/AndroidRuntime(16907): at java.lang.reflect.Method.invoke(Method.java:511)
03-26 07:35:23.140: E/AndroidRuntime(16907): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-26 07:35:23.140: E/AndroidRuntime(16907): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-26 07:35:23.140: E/AndroidRuntime(16907): at dalvik.system.NativeStart.main(Native Method)
pls help . how do i rectify it??
Upvotes: 0
Views: 79
Reputation: 3030
Not much to go on here, but I'm gonna take a stab at it and say that you didn't initialize your db before trying to access it. That would give a nullpointer on that row.
Upvotes: 1