So, the issue is simple. I am updating into a table, and the primary key is autoincrementing... This means that all related tables are screwed over. I am using sqlite, so I don't think there is any inherent mechanism that can catch this and related tables.
Due to a lack of support for foreign keys in the sqlite versions I must work with, I force the relations by adding the primary key returned from an insert into the parent table into the related tables when entering new data.
Is there an alternative to updating all related tables each time I do an update? Please say yes..
Edit: last edit was wrong, I got confused. I have simply pasted the code governing inserts/replacements below. I am replacing into, not updating into, typing error on my part.
//inserts
public long insertIntoCompany(String company, int subs) {
ContentValues cv = new ContentValu开发者_StackOverflow社区es();
cv.put(company_column, company);
cv.put(company_subscribed_column, subs);
return db.replace(company_table, null, cv);
}
You should actually be using the SQL update
query. See this answer.
If you paste your query we might be able to offer more help.
精彩评论