0

i have create next table:

final String SQL_CREATE_TABLE_NEWS_TAPE = "CREATE TABLE " + NewsTapeEntry.TABLE_NAME +
                " (" + NewsTapeEntry.NEWS_ID + " INTEGER PRIMARY KEY, " +
                NewsTapeEntry.USER_ID + " INTEGER NOT NULL, " +
                NewsTapeEntry.CONTENT + " TEXT, " +
                NewsTapeEntry.CREATED_AT + " TEXT, " +

                " FOREIGN KEY (" + NewsTapeEntry.NEWS_ID + ") REFERENCES " +
                NewsTapeEntry.TABLE_NAME + " (" + NewsTapeEntry.NEWS_ID + "), " +
                " UNIQUE (" + NewsTapeEntry.NEWS_ID + ") ON CONFLICT UPDATE);";

but if i make update myNews, it is every time insert each row in this table... And I need the next result: when its updating - firs check if current ID exist, if true - update current row in table, if false - make insert! But there is small point, that must be done: if ID exist, and row updating, it must not overwrite the empty fields with default value. For example: i am updating myNews, i receive the answer with existed NEWS_ID, but in this answer are not consist field CREATED_AT. so after updating the row field CREATED_AT must be previous(not updated and not replaced by default value).

will be glad any solutions!

UPDATE

when i finish receive new data, i am doing bulckIncert:

getContentResolver().bulkInsert(Contract.NewsTapeEntry.CONTENT_URI, mCvArray);
Stan Malcolm
  • 2,740
  • 5
  • 32
  • 53

0 Answers0