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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:44:35+00:00 2026-06-18T02:44:35+00:00

I’m trying to put in sqldatabase 2 columns. When I insert coment all is

  • 0

I’m trying to put in sqldatabase 2 columns.
When I insert coment all is good, but when I try to read listView I have error. column '_id' does not exist
There is logcat:

    01-25 12:30:55.787: E/AndroidRuntime(4256): FATAL EXCEPTION: main
01-25 12:30:55.787: E/AndroidRuntime(4256): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.spacebrowser/com.example.spacebrowser.books}: java.lang.IllegalArgumentException: column '_id' does not exist

There is Sqliteadapter

    public class SQLiteAbdapter {
public static final String MYDATABASE_NAME = "MY_DATABASES";
public static final String MYDATABASE_TABLE = "MY_TABLE";
public static final int MYDATABASE_VERSION = 1;
public static final String KEY_ID = "_id";
public static final String KEY_CONTENT1 = "Content1";
public static final String KEY_CONTENT2 = "Content2";


private static final String SCRIPT_CREATE_DATABASE =
 "create table " + MYDATABASE_TABLE + " ("
 + KEY_ID + " integer primary key autoincrement, "
 + KEY_CONTENT1 + " text not null, "
 + KEY_CONTENT2 + " text not null);"; 

private SQLiteHelper sqLiteHelper;
private SQLiteDatabase sqLiteDatabase;
private Context context;
public SQLiteAbdapter(Context c){

 context = c;

} 

public SQLiteAbdapter openToRead() throws android.database.SQLException {
 sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null, MYDATABASE_VERSION);
 sqLiteDatabase = sqLiteHelper.getReadableDatabase();
 return this; 

} 

public SQLiteAbdapter openToWrite() throws android.database.SQLException {
 sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null, MYDATABASE_VERSION);
 sqLiteDatabase = sqLiteHelper.getWritableDatabase();
 return this; 

}

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

public long insert(String content1, String content2){

 ContentValues contentValues = new ContentValues();
 contentValues.put(KEY_CONTENT1, content1);
 contentValues.put(KEY_CONTENT2, content2);  


 return sqLiteDatabase.insert(MYDATABASE_TABLE, null, contentValues);
} 

public int deleteAll(){
 return sqLiteDatabase.delete(MYDATABASE_TABLE, null, null);
}
public Cursor queueAll(){
 String[] columns = new String[]{KEY_ID, KEY_CONTENT1, KEY_CONTENT2};
 Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns,
 null, null, null, null, null, null);
   return cursor;

} 

 public class SQLiteHelper extends SQLiteOpenHelper {
public SQLiteHelper(Context context, String name,
CursorFactory factory, int version) {
super(context, name, factory, version);

}

@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL(SCRIPT_CREATE_DATABASE);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
 // TODO Auto-generated method stub   
    if (oldVersion >= newVersion)
        return;
    db.execSQL("DROP TABLE IF EXISTS " + MYDATABASE_TABLE);
    onCreate(db);
}
    }

  } 

and there is books.java simplecursoradapter:

ListView listContent;   
  private SQLiteAbdapter mySQLiteAdapter;
  SimpleCursorAdapter cursorAdapter;
  Cursor cursor;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.books);

    listContent = (ListView)findViewById(R.id.list);
    mySQLiteAdapter = new SQLiteAbdapter(this);
    mySQLiteAdapter.openToRead();        

    cursor = mySQLiteAdapter.queueAll();
    String[] from = new String[]{SQLiteAdapter.KEY_ID, SQLiteAbdapter.KEY_CONTENT1, SQLiteAbdapter.KEY_CONTENT2};
    int[] to = new int[]{R.id.id, R.id.title, R.id.urlss};
    cursorAdapter =
     new SimpleCursorAdapter(this, R.layout.bookmark, cursor, from, to);
    listContent.setAdapter(cursorAdapter);    

What I am do so bad, that I have this error?

column '_id' does not exist
  • 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-18T02:44:36+00:00Added an answer on June 18, 2026 at 2:44 am

    you missed to insert the id in your insert method. So you will add that

    public long insert(String id,String content1, String content2){
    
      ContentValues contentValues = new ContentValues();
      contentValues.put(KEY_ID, id);
      contentValues.put(KEY_CONTENT1, content1);
       contentValues.put(KEY_CONTENT2, content2);  
    
    
     return sqLiteDatabase.insert(MYDATABASE_TABLE, null, contentValues);
    
     } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.