How to update my string value into database

前端 未结 5 1773
粉色の甜心
粉色の甜心 2021-01-03 18:59

Have a database with table name status and column name is column1. I need to update this.

I have a String value in Activity1 <

5条回答
  •  既然无缘
    2021-01-03 19:25

    You can Directly Execute this Query like:

    db.execSQL("update status SET column1 = '"+prms+"' ", null);
    

    You should replace your code

    Cursor cursor = db.execSQL("update status SET column1 = '"+prms+"' ", null);
    

    With

    db.execSQL("update status SET column1 = '"+prms+"' ", null);
    

    void execSQL(String sql)

    Execute a single SQL statement that is NOT a SELECT or any other SQL statement that returns data.

    It has no means to return any data (such as the number of affected rows). Instead, you're encouraged to use insert(String, String, ContentValues, update(String, ContentValues, String, String[]), et al, when possible.

提交回复
热议问题