SQLite数据库增加查询

package liziqiang.bawei.com.lziqiang20180921;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class DButls {
private SQLiteDatabase db;
public DButls (Context context) {
DBhelper dBhelper = new DBhelper(context,“news.db”,null,1);
db= dBhelper.getWritableDatabase(); // 没有赋值

}
    public long insert(String data){
        ContentValues contentValues = new ContentValues();
        contentValues.put("data",data);
        return db.insert("news",null,contentValues);
    }

public String qure(){
Cursor news = db.rawQuery(“select data from news”,null);
String data = “”;
while (news.moveToNext()){
data = news.getString(news.getColumnIndex(“data”));// 没加双引号
// Log.i(“大萨达所”, "qure: "+data);
}
return data;
}

};

猜你喜欢

转载自blog.csdn.net/weixin_43191402/article/details/82832030