I am trying to insert data in a database table signals, which has 5 columns(id,SSID,BSSID, RSSID, Poloha
).
I am getting an Error in Logcat:
E/SQLiteLog﹕ (1) table signals has no column named RSSID
E/SQLiteDatabase﹕ Error inserting BSSID=a0:f3:c1:d4:c0:79 RSSID=49 SSID=AIESECFlat Poloha=PCstol
android.database.sqlite.SQLiteException: table signals has no column named RSSID (code 1): , while compiling: INSERT INTO signals(BSSID,RSSID,SSID,Poloha) VALUES (?,?,?,?)"
I can't figure out why it doesn't create all columns. Thanks for any advice :)
MAIN ACTIVITY
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DatabaseHandler db = new DatabaseHandler(this);
// Inserting Contacts
db.addSignals(new Signals("AIESECFlat","a0:f3:c1:d4:c0:79","49","PCstol"));
}
DatabaseHandler class
public class DatabaseHandler extends SQLiteOpenHelper{
// All Static variables
private static final int DATABASE_VERSION = 1; // Database Version
// Database Name
private static final String DATABASE_NAME = "localizationManager";
// Signals table name
private static final String TABLE_SIGNALS = "signals";
// Signals Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_SSID = "SSID";
private static final String KEY_BSSID = "BSSID";
private static final String KEY_RSSID = "RSSID";
private static final String KEY_Poloha = "Poloha";
public DatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db){
String CREATE_SIGNALS_TABLE = "CREATE TABLE "+TABLE_SIGNALS +"("
+ KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_SSID + " TEXT,"
+ KEY_BSSID + " TEXT"
+ KEY_RSSID + " TEXT"
+ KEY_Poloha + " TEXT"
+ ")";
db.execSQL(CREATE_SIGNALS_TABLE);
}
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_SIGNALS);
// Create tables again
onCreate(db);
}
public void addSignals(Signals signals){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_SSID,signals.get_SSID()); //signal SSID
values.put(KEY_BSSID, signals.get_BSSID());
values.put(KEY_RSSID, signals.get_RSSID());
values.put(KEY_Poloha, signals.get_poloha());
//Inserting Row
db.insert(TABLE_SIGNALS, null, values);
db.close(); //closing database connetion
}
}
Signal class public class Signals {
//private variables
int _id;
String _SSID;
String _BSSID;
String _RSSID;
String _poloha;
//Empty constructor
public Signals(){ }
//constructor
public Signals(String _SSID, String _BSSID, String _RSSID, String _poloha) {
this._SSID = _SSID;
this._BSSID = _BSSID;
this._RSSID = _RSSID;
this._poloha = _poloha;
}
public String get_SSID() {
return _SSID;
}
public String get_BSSID() {
return _BSSID;
}
public String get_RSSID() {
return _RSSID;
}
public String get_poloha() {
return _poloha;
}
Aucun commentaire:
Enregistrer un commentaire