SQLite ORDER BY string containing number starting with 0

后端 未结 5 2141
小蘑菇
小蘑菇 2020-12-13 06:44

as the title states:

I have a select query, which I\'m trying to \"order by\" a field which contains numbers, the thing is this numbers are really strings starting w

5条回答
  •  Happy的楠姐
    2020-12-13 07:26

    In ListView with cursor loader!

    String projection= some string column;
    String selection= need to select;
    
    String sort="CAST ("+ YOUR_COLUMN_NAME + " AS INTEGER)";
    
    CursorLoader(getActivity(), Table.CONTENT_URI, projection, selection, selectionArgs, sort);
    

提交回复
热议问题