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 9239177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:55:39+00:00 2026-06-18T07:55:39+00:00

I use the following code to create database in my android application. Actually, In

  • 0

I use the following code to create database in my android application. Actually, In need to copy data from another table to this table. It only copied 10868 records, but the original table contains 24000 records.

I checked and finally found at the 10869 record, there is a null value on one of the field. But I didn’t specify “not null ” during table creation. But this table caan’t accept null values.

private static final String SCRIPT_CREATE_DATABASE1 =
          "create table " + MYDATABASE_TABLE2 + " ("
          + KEY_ID + " integer primary key autoincrement, "
          + KEY_RCODE + " text, "
          + KEY_RNAME + " text);";

Is there any other ways to allow columns to accept null values? I really confused

Edit: Android code

try
    {
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://moberp.svsugar.com:8080/androidservlt/ryotmas");
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity entity = response.getEntity();
    is = entity.getContent();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                is, "iso-8859-1"), 8);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
        is.close();
        json = sb.toString();

    } catch (Exception e) {
    Toast.makeText(getBaseContext(), "Buffer Error"+"Error converting result"+e.toString(), Toast.LENGTH_LONG).show();
    }

    try {
        jObj = new JSONObject(json);
        contacts = jObj.getJSONArray("get");
        for(int i = 0; i < contacts.length(); i++){
        JSONObject c = contacts.getJSONObject(i);
            rcode = c.getString("rcode");
            rname = c.getString("rname");
            radapter.insert(rcode, rname);
        }
        Toast.makeText(getBaseContext(), " Ryot BackUp completed", Toast.LENGTH_SHORT).show();

    } catch (JSONException e) {
        Toast.makeText(getBaseContext(), "Error"+e.toString(), Toast.LENGTH_LONG).show();
    }
  • 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-06-18T07:55:40+00:00Added an answer on June 18, 2026 at 7:55 am

    You are not checking if the values you are retreiving from the JSON object actually have a value.

    If they do not have a value that they can cast to the type you are retreiving, they will throw a JSONException.

    You can easily do this check with IsNUll

    JSONObject c = contacts.getJSONObject(i);
                rcode = c.getString("rcode");
    
                if(!c.isNull("rname"))
                {
                  rname = c.getString("rname");
                }
                else
                {
                  rname = ""; //or rname = null, whatever you want
                }
                radapter.insert(rcode, rname);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use following code: Create a retry policy, when error, retry after 1 second,
I use the following code try to create an array of string vectors, I
I use the following code to copy a particular directory and its contents to
Exception: CREATE TABLE android_metadata failed Failed to setLocale() when constructing, closing the database android.database.sqlite.SQLiteException:
I'm learning PHP MYSQL and trying to create a database. I'm following this tutorial
I am developing Android application which Gets and Posts data to database through REST
Is the following code correct to create a database in php? <?php $con=mysql_connect('localhost','admin','admin'); if(!$con)
In my view I use the following code to get an image from my
Hi i am developing android application, And now i have to use sqlite database
I use the following code to query my websql database to see if there

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.