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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:29:15+00:00 2026-06-05T09:29:15+00:00

I have a problem creating a database with 2 columns. In the first one

  • 0

I have a problem creating a database with 2 columns.
In the first one there should be a name and in the second one a number.
Creating the name database is no problem, but when I try to add the second column I get the error message "I/Database(13531): sqlite returned: error code = 1, msg = no such column: zahl"

my code is here

first the Manager

package my.studienarbeit.bestimmung.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DatenbankManager extends SQLiteOpenHelper {

private static final String DB_NAME = "carbohydrates.db";
private static final int DB_VERSION = 1;

private static final String WEIGHT_CREATE = 
         "CREATE TABLE weight (" 
        + "_id INTEGER PRIMARY KEY AUTOINCREMENT, " 
        +   "name TEXT NOT NULL, " +
    //  +   "zahl INTEGER" +
        ")";


public DatenbankManager(Context context) {
    super(context, DB_NAME, null, DB_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL(WEIGHT_CREATE);

}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Log.w(DatenbankManager.class.getName(),
        "Upgrading database from version " + oldVersion + " to "
                + newVersion + ", which will destroy all old data");
    db.execSQL("DROP TABLE IF EXISTS SCANITEM");
    onCreate(db);
}

}

and my database:

package my.studienarbeit.bestimmung.database;

import my.studienarbeit.bestimmung.R;
import android.app.ListActivity;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.SimpleCursorAdapter;
import android.widget.Toast;

public class Datenbanken extends ListActivity {

private SQLiteDatabase mDatenbank;
private DatenbankManager mHelper;
/*/ private static final String WEIGHT_SELECT_RAW = 
        "SELECT _id, name, zahl FROM weight" ; //*/
        
//*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.daten_datenbanken);
    mHelper = new DatenbankManager(this);
    mHelper.getWritableDatabase();
    
}

@Override
protected void onPause() {
    super.onPause();
    mDatenbank.close();
    Toast.makeText(this, 
                 getResources().getString(R.string.tx_daten_datenbanken_db_geschlossen), 
            Toast.LENGTH_SHORT).show();
}

@Override
protected void onResume() {
    super.onResume();
    mDatenbank = mHelper.getWritableDatabase();
    Toast.makeText(
            this, 
            getResources().getString(
                    R.string.tx_daten_datenbanken_db_geoeffnet
                    ), 
            Toast.LENGTH_SHORT)
    .show();
    ladeDaten();

}

private void ladeDaten() {
     // Cursor weightCursor = mDatenbank.rawQuery(WEIGHT_SELECT_RAW, null);
Cursor weightCursor = mDatenbank.query("weight",
            new String [] {
                    "_id",
                    "name",
                //  "zahl",
            },
            null, null, null, null, null                
        ); 

    startManagingCursor(weightCursor);  
    SimpleCursorAdapter weightAdapter =
            new SimpleCursorAdapter(this, 
                    android.R.layout.simple_list_item_2, 
                    weightCursor, 
                    new String [] {
                    "name", 
                //  "zahl"
                    }, 
                    new int[] {
                        android.R.id.text1
                    }
                    
            );

setListAdapter(weightAdapter);
}

public void onNavButtonClick(View view) {
    EditText et_c = 
            (EditText) findViewById(R.id.editText_name_c);
//  EditText et_w = 
    //      (EditText) findViewById(R.id.editText_weight_c);
    
    ContentValues werte = new ContentValues();
    werte.put("name", et_c.getText().toString());
//  werte.put("zahl", et_w.getText().toString());
    mDatenbank.insert("weight", null, werte);
    ladeDaten();
    et_c.setText("");
//  et_w.setText("");

The 2nd column is not active right now for debug functions.

  • 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-05T09:29:17+00:00Added an answer on June 5, 2026 at 9:29 am

    If you first created your table without the "zahl" column, then added the "zahl" column and rerun your application, the OpenHelper did not do the "onCreate" again with the new values. My suggestion is that you first drop the table (on emulator, go to Settings > Applications > Yourapp > Click "Clear Data" button), then uncomment the "zahl" lines (especially in DatenbankManager.java), then recompile + run. Running your app again, with an empty database, will recreate the table with column "zahl".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have problem with creating a simple MySQL trigger in C#. I'm using StringBuilder
I have a problem creating a std::map<int, int> from a vector of pointers, called
I have a problem creating the following SQL Statement using LINQ & C# select
I have a problem creating and executing a JAR file. I have already made
I am working on creating website with Yii framework and I have a problem
im currently creating a graph for an app, using coreplot and have a problem
i have a small problem, i am creating a edit page in my asp.net
I have run into a strange problem, i am creating a lot of dynamically
I'm creating an Android game and I encountered a problem. I have 2 threads:

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.