如果我想交换我的android数据库的内容,怎么办,如下所示:

之前

1     hello    world
2     Android  Nougat




1     Android  Nougat
2     hello    world

最佳答案

您无需更改数据库中的位置。您需要将其他int值添加到数据库(不是id)。并根据新位置更改此值。对于第一个对象,将其设置为2;一秒钟-1.然后,当您从数据库中检索数据时,只需根据该值对其进行排序。



String orderBy =  "POSITION ASC";
Cursor cursor = database.query(TABLE_NAME, logTableColumns, null, null,
     null, null, orderBy);

10-02 02:08
查看更多