Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7675137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:53:37+00:00 2026-05-31T16:53:37+00:00

here’s the code(Where I think the NullPointerException is generated): public String getData(String s1,String s2,String

  • 0

here’s the code(Where I think the NullPointerException is generated):

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) && c.getString(cst2).equals(s2) && c.getString(cst3).equals(s3) && c.getString(cst4).equals(s4))
                result = c.getString(calpha);
            else
                result = null;

        }

        return result;
    }

Log content:

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:53:38+00:00Added an answer on May 31, 2026 at 4:53 pm

    Either:

    • One of the four strings being passed in is null. Check the strings being passed in, right at the start of the method.

    or

    • One of the strings being pulled from the database is null. And add some logging to see if any of the strings from the DB are null.

    If you want two null strings to be regarded as equal, then you need to expand your comparison as follows:

    if ((s1 == null && c.isNull(cst1)) || 
        (s1 != null && !c.isNull(cst1) && s1.equals(c.getString(cst1)))
        ... repeat for the other three string-pairs       
       ) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is what I am trying to achieve in PHP: I have this string:
Here a simple question : What do you think of code which use try
Here my code: $(document).ready(function() { $('#mid_select').live('click', function(e){ $('#middle').load( $(this).attr('href') + ' #middle'); var page
Here is my code, which takes two version identifiers in the form 1, 5,
Here's a coding problem for those that like this kind of thing. Let's see
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();
Here is an example: I write html code inside of textarea, then I swap
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here is the css: #content ul { font-size: 12px; } I am trying this:
Here is some code on the javascript side for form-based uploads: iframe.setAttribute('src', 'javascript:false;'); I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.