NullPointerException in android,maybe a database issue
<p>here's the code(Where I think the NullPointerException is generated):</p>

<pre><code>public String getData(String s1,String s2,String s3,String s4){

        DatabaseHelper databaseHelper = new DatabaseHelper(this);
        SQLiteDatabase db = databaseHelper.getWritableDatabase();

        String columns[] = new String[]{"alphabet","st1","st2","st3","st4" };
        Cursor c = db.query("capitals", columns, null, null,null,null, null);
        String result = "";

        int calpha = c.getColumnIndex("alphabet");
        int cst1 = c.getColumnIndex("st1");
        int cst2 = c.getColumnIndex("st2");
        int cst3 = c.getColumnIndex("st3");
        int cst4 = c.getColumnIndex("st4");

        for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){

            if(c.getString(cst1).equals(s1) &amp;&amp; c.getString(cst2).equals(s2) &amp;&amp; c.getString(cst3).equals(s3) &amp;&amp; c.getString(cst4).equals(s4))
                result = c.getString(calpha);
            else
                result = null;

        }

        return result;
    }
</code></pre>

<p>Log content:</p>

<pre><code>03-19 21:27:34.263: E/AndroidRuntime(26498): FATAL EXCEPTION: main
03-19 21:27:34.263: E/AndroidRuntime(26498): java.lang.NullPointerException
03-19 21:27:34.263: E/AndroidRuntime(26498):    at learn.myandroidapp.hr.HandwritingRecognitionCanvas.getData(HandwritingRecognitionCanvas.java:213)
03-19 21:27:34.263: E/AndroidRuntime(26498):    at learn.myandroidapp.hr.HandwritingRecognitionCanvas$1.onClick(HandwritingRecognitionCanvas.java:103)
03-19 21:27:34.263: E/AndroidRuntime(26498):    at android.view.View.performClick(View.java:3511)
03-19 21:27:34.263: E/AndroidRuntime(26498):    at android.view.View$PerformClick.run(View.java:14105)
03-19 21:27:34.263: E/AndroidRuntime(26498):    at android.os.Handler.handleCallback(Handler.java:605)
03-19 21:27:34.263: E/AndroidRuntime(26498):    at android.os.Handler.dispatchMessage(Handler.java:92)
03-19 21:27:34.263: E/AndroidRuntime(26498):    at android.os.Looper.loop(Looper.java:137)
03-19 21:27:34.263: E/AndroidRuntime(26498):    at android.app.ActivityThread.main(ActivityThread.java:4424)
03-19 21:27:34.263: E/AndroidRuntime(26498):    at java.lang.reflect.Method.invokeNative(Native Method)
03-19 21:27:34.263: E/AndroidRuntime(26498):    at java.lang.reflect.Method.invoke(Method.java:511)
03-19 21:27:34.263: E/AndroidRuntime(26498):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-19 21:27:34.263: E/AndroidRuntime(26498):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-19 21:27:34.263: E/AndroidRuntime(26498):    at dalvik.system.NativeStart.main(Native Method)
03-19 21:27:36.604: I/Process(26498): Sending signal. PID: 26498 SIG: 9
</code></pre>
