Note that there are some explanatory texts on larger screens.

plurals
  1. POSQLite Database
    primarykey
    data
    text
    <p>I'm trying to make a database in android but I have this problem,erase the database file in the (AVD), rename the database in the class "phone", but nothing works! </p> <p><code>02-11 13:00:27.491: E/Database(487): android.database.sqlite.SQLiteException: table Phones_Table has no column named nam: , while compiling: INSERT INTO Phones_Table(nam, tel) VALUES(?, ?);</code></p> <p>this is my code: </p> <pre><code>public class Phones { public static final String ID_ROW = "_id"; public static final String ID_PERSON = "nam"; public static final String ID_PHONE = "tel"; private static final String N_DB = "Phones"; private static final String N_TABLE = "Phones_Table"; private static final int VERSION_DB = 1; private DBHelper nHelper; private final Context nContext; private SQLiteDatabase nDB; private static class DBHelper extends SQLiteOpenHelper{ public DBHelper(Context context) { super(context, N_DB, null, VERSION_DB); // TODO Auto-generated constructor stub } @Override public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub db.execSQL("CREATE TABLE " + N_TABLE + "(" + ID_ROW + " INTEGER PRIMARY KEY AUTOINCREMENT, "+ ID_PERSON + "TEXT NOT NULL, "+ ID_PHONE + "TEXT NOT NULL);" ); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub db.execSQL("DROP TABLE IF EXISTS " + N_TABLE); onCreate(db); } } public Phones (Context c){ nContext = c; } public Phones open() throws SQLException{ nHelper = new DBHelper(nContext); nDB = nHelper.getWritableDatabase(); return this; } public void close() { // TODO Auto-generated method stub nHelper.close(); } public long createEntry(String nam, String tel) { // TODO Auto-generated method stub //insert data ContentValues cv = new ContentValues(); //put content of name cv.put(ID_PERSON, nam); //put content of Phone cv.put(ID_PHONE, tel); //return content in table return nDB.insert(N_TABLE, null, cv); } public String receive() { // TODO Auto-generated method stub String[] columns = new String[]{ID_ROW, ID_PERSON, ID_PHONE}; Cursor c = nDB.query(N_TABLE, columns, null, null, null, null, null); String result = ""; int iRow = c.getColumnIndex(ID_ROW); int iName = c.getColumnIndex(ID_PERSON); int iPhone = c.getColumnIndex(ID_PHONE); //loop for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){ result = result + c.getString(iRow) + " " + c.getString(iName) + " " + c.getString(iPhone) + "\n "; } return result; }} </code></pre> <p>really would appreciate your help</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload