Android SQLite INSERT or REPLACE

I am trying to use the INSERT or REPLACE syntax in SQLite without success as the rows are not inserted.

My request to create a table

 create table providers (provider_id text not null, provider_name text not null,  provider_channel_id text not null, channel_name text not null);CREATE UNIQUE INDEX channel_id ON providers (provider_channel_id);

My INSERT or Replace request

INSERT OR REPLACE INTO providers (provider_channel_id, channel_name, provider_id, provider_name) VALUES ('1', '2', '3', '4')

thank

+5
source share
2 answers

Take a look at this post: (assuming you viewed Sieryuu's comment)

How to update a row in a table or insert it if it does not exist?

you can just replace the string.

+4
source

the solution I found. Replace instead of pasting you should also have the row id in the table and set it as PRIMARY KEY

 bdd.replace(table,null, contentValues);
+3
source

All Articles