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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:35:51+00:00 2026-06-16T08:35:51+00:00

Can somebody help me I wrote this app, but it doesn’t work and I

  • 0

Can somebody help me I wrote this app, but it doesn’t work and I don’t find the solution.

1st error:

java.lang.illegalstateexception could not read row 0 col 1 from cursor window. Make sure the cursor is initialized correctly before accessing data from it

2nd error:

android.database.sqlite.SQLite Exception: near “=”: syntax error (code 1): while compiling: SELECT ZAHL1 FROM Verlauf WHERE ID =

package com.example.to_doliste2;

import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivityT extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_t);
        datasource = new VerlaufDataSource(this);

    }

    private VerlaufDataSource datasource;

    List<Entry> AufgabenListe = new ArrayList<Entry>();

    public void VerlaufKlick(View view)
    {
        try
        {
        String zahl1;
        EditText Feld1 = (EditText)findViewById(R.id.editText1);

        if (Feld1.getText().toString().length() == 0)
                {
            return;
                }

        zahl1 = (Feld1.getText().toString());

        Feld1.setText(String.valueOf(zahl1));




        try
        {
            datasource.open();
            datasource.createEntry(zahl1);
            datasource.close();         
        }
        catch (Exception ex)
        {
            Toast.makeText(this,ex.toString(),Toast.LENGTH_LONG).show();
        }



        AufgabenListe.clear();
        try
        {
            datasource.open();
            AufgabenListe = datasource.getAllEntries();
            datasource.close();
        }
        catch (Exception ex)
        {
            Toast.makeText(this,ex.toString(),Toast.LENGTH_LONG).show();
        }


        ArrayAdapter<Entry> adapterVerlauf = new ArrayAdapter<Entry>(MainActivityT.this, android.R.layout.simple_list_item_1, AufgabenListe);

        ListView lVerlauf = (ListView)findViewById(R.id.listView1);
        lVerlauf.setAdapter(adapterVerlauf);
        }
        catch (Exception ex)
        {
            Toast.makeText(this,ex.toString(),Toast.LENGTH_LONG).show();
        }

    }



}
package com.example.to_doliste2;

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


    public class MySQLHelper extends SQLiteOpenHelper {

        public static final String DATABASE_NAME = "verlaufAufgaben.db";
        public static final int DATABASE_VERSION = 1;

        private static final String TABLE_CREATE_VERLAUF = ""
                +"create table VERLAUF ("
                +" ID integer primary key, "
                +" Zahl1 int) ";

        public MySQLHelper(Context context) 
        {   
            super (context, DATABASE_NAME, null, DATABASE_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase database)
        {
            database.execSQL(TABLE_CREATE_VERLAUF);
        }


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

    }
package com.example.to_doliste2;

public class Entry {
    private int zahl1;

    public int getZahl1()
    {
        return zahl1;
    }

    public void setZahl1(int zahl1)
    {
        this.zahl1 = zahl1;
    }


    @Override
    public String toString()
    {
        return String.format("%d", zahl1);
    }

}
package com.example.to_doliste2;

import java.util.ArrayList;
import java.util.List;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;

public class VerlaufDataSource {

    private SQLiteDatabase database;
    private MySQLHelper dbHelper;
    private String[] allColumns = {"ZAHL1"};


    public VerlaufDataSource(Context context)
    {
        dbHelper = new MySQLHelper(context);
    }

    public void open() throws SQLException
    {
        database = dbHelper.getWritableDatabase();
    }

    public void close()
    {
        dbHelper.close();
    }

    public Entry createEntry(String zahl1)
    {
        ContentValues values = new ContentValues();
        values.put("ZAHL1", zahl1);

        long insertId = database.insert("Verlauf", null, values);

        Cursor cursor = database.query("Verlauf", allColumns, "ID = " + insertId, null, null, null, null);
        cursor.moveToFirst();

        return cursorToEntry(cursor);



    }

    protected List<Entry> getAllEntries()
    {
        List<Entry> EntriesList = new ArrayList<Entry>();
        EntriesList = new ArrayList<Entry>();

        Cursor cursor = database.query("Verlauf", allColumns, "ID =" , null, null, null, null, null);
        cursor.moveToFirst();

        if(cursor.getCount() == 0) return EntriesList;

        while (cursor.isAfterLast()==false)
        {
            Entry entry = cursorToEntry(cursor);
            EntriesList.add(entry);
            cursor.moveToNext();
        }

        cursor.close();

        return EntriesList;
    }

    private Entry cursorToEntry(Cursor cursor)
    {
        Entry entry = new Entry();
        entry.setZahl1(cursor.getInt(1));

        return entry;
    }
}
  • 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-16T08:35:53+00:00Added an answer on June 16, 2026 at 8:35 am

    if you are retrieving all columns from database then change your query as:

     Cursor cursor = database.query("Verlauf", 
                               allColumns, null, null, null, null, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can somebody help me with this. There is HTML code: <h3> <label> <input type=checkbox
Can somebody help me to center the buttons horizontally of a form? I don't
Heyy can somebody help me ? i have this issue that still do know
Sure it's a simple question, but I can't fix it, can somebody help me?
can somebody explain me what does this error mean: > ./rank lines.in 'nknown option:
Can somebody help me? The following code works, but unfortunately a function call to
Can somebody help me with the proper way to deserialize json in this format:
Can somebody please help me to write a DeepCopy routine for this matrix class
I hope this is the right place to post this and somebody can help.
I hope somebody can help me. I've been trying to write a custom html

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.