我正在开发一个Android应用程序,我有一个问题我无法解决。我希望你们能帮助我。
我收到此错误:
require "active_support/all"
require "net/http"
token = "my_token"
url = "https://graph.facebook.com/v2.6/me/messages?"
sender = 100688998246663
text = "Hello"
request_params = {
recipient: {id: sender},
message: {text: text},
access_token: token
}
request_header = { 'Content-Type': 'application/json' }
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(uri.path, request_header)
request.body = request_params.to_json
http.request(request)
response = http.request(request)
就像你们都知道的那样,错误是它无法找到表格。但我做了桌子。
android.database.sqlite.SQLiteException: table FBFriends has no column named id (code 1): , while compiling: INSERT INTO FBFriends(id,name) VALUES (?,?)
这是向数据库添加数据的功能。
public DatabaseManager(Context context) {
//referentie naar cursus
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
//SQL for creating a new table
Log.d(TAG, "Tabel gemaakd");
String CREATE_DATABASE_TABLE ="CREATE TABLE Friends (id VARCHAR(255) PRIMARY KEY not null , name VARCHAR(255) )";
db.execSQL(CREATE_DATABASE_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Drop older database if existed
db.execSQL("DROP TABLE IF EXISTS Friends");
Log.d(TAG, "Tabel verwijdert");
// create new table
this.onCreate(db);
}
谢谢你们!
此致 斯泰恩
答案 0 :(得分:1)
它是因为你还有旧桌子,没有新桌子。首先要看,在创建一个名称表后,不要直接在你的onCreate数据库帮助器中更改名称表。因为它只在第一次执行时创建表。如果要更改名称表,只需创建一个函数以使用alter table query并使用新名称表更改旧名称表。