java - How to fix [The method put(String, Boolean) in the type ContentValues is not applicable for the arguments (Boolean, Boolean)] -


i'm trying learn how develop android app , trying re-write notepadv3solution {http://developer.android.com/training/notepad/index.html} modifying own purposes.

in method createtask (nr bottom), error the method put(string, boolean) in type contentvalues not applicable arguments (boolean, boolean). i've added boolean field database, adding createtask method. how can boolean field work?

package com.superiorxc.taskcentral;  import android.content.contentvalues; import android.content.context; import android.database.cursor; import android.database.sqlexception; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sqliteopenhelper; import android.util.log;  public class tasksdbadapter {      public static final string key_rowid = "_id";     public static final string key_title = "title";     public static final string key_body = "body";     public static final boolean key_complete = true;      private static final string tag = "tasksdbadapter";     private databasehelper mdbhelper;     private sqlitedatabase mdb;          /**      * database creation sql statement      */     private static final string database_create =         "create table tbl_tasks (_id integer primary key autoincrement, "         + "title text not null, body text, complete boolean not null);";      private static final string database_name = "db_taskcentral";     private static final string database_table = "tbl_tasks";     private static final int database_version = 1;      private final context mctx;          private static class databasehelper extends sqliteopenhelper {          databasehelper(context context) {             super(context, database_name, null, database_version);         }          @override         public void oncreate(sqlitedatabase db) {              db.execsql(database_create);         }          @override         public void onupgrade(sqlitedatabase db, int oldversion, int newversion) {             log.w(tag, "upgrading database version " + oldversion + " "                     + newversion + ", destroy old data");             db.execsql("drop table if exists tbl_tasks");             oncreate(db);         }     }          /**      * constructor - takes context allow database      * opened/created      *       * @param ctx context within work      */     public tasksdbadapter(context ctx) {         this.mctx = ctx;     }      /**      * open db_taskcentral database. if cannot opened, try create new      * instance of database. if cannot created, throw exception      * signal failure      *       * @return (self reference, allowing chained in      *         initialization call)      * @throws sqlexception if database neither opened or created      */     public tasksdbadapter open() throws sqlexception {         mdbhelper = new databasehelper(mctx);         mdb = mdbhelper.getwritabledatabase();         return this;     }      public void close() {         mdbhelper.close();     }         /**      * create new task using title , body provided. if task      * created return new rowid note, otherwise return      * -1 indicate failure.      *       * @param title title of task      * @param body body of task      * @return rowid or -1 if failed      */     public long createtask(string title, string body, boolean complete) {         contentvalues initialvalues = new contentvalues();         initialvalues.put(key_title, title);         initialvalues.put(key_body, body);         initialvalues.put(key_complete,complete);           return mdb.insert(database_table, null, initialvalues);     }      } 

change key_complete

public static final string key_complete = "complete"; 

you want reference named column in database.

you can think of contentvalues map<string,object> key name of database column , object want put row column.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -