Error executing delete on Sqlite bank

3

I have a problem with my Android project. When I run a delete on the sqlite database, I get the following log message as a return:

W/FileUtils: Failed to chmod(/storage/sdcard/Cardapio Digital/Database/dbcardapio.sqlite): 
android.system.ErrnoException: chmod failed: EPERM (Operation not permitted)

public class OrdersDao {

Context context;
variaveis v;
SQLiteDatabase db;


public PedidosDao(Context context, variaveis v) {
    this.v = v;
    this.context = context;
}

public void deletaItem(int codigo){
    db = context.openOrCreateDatabase(v.getPathBanco(),Context.MODE_WORLD_WRITEABLE,null);

    try{

        db.execSQL("DELETE FROM PEDIDOS WHERE ID = "+codigo+" ");

    }catch(Exception e){
        e.printStackTrace();
    }
    db.close();
}
    
asked by anonymous 01.11.2017 / 15:42

1 answer

4

I think the code is wrong. you are putting double quotation marks around double quotation marks without the single quotes (let's say he needs to understand that it's a string) .......

Please try the following:

db.execSQL("DELETE FROM PEDIDOS WHERE ID = '"+codigo+"';");

or else:

db.execSQL("DELETE FROM PEDIDOS WHERE ID = "+codigo);


Editing:
The description of the error appears to indicate that some permission is missing. Try putting these lines in your manifest.xml:

"android.permission.WRITE_EXTERNAL_STORAGE"
    
01.11.2017 / 20:08