是否有可能在sqlite android中洗牌一列的数据? 我有两列从中我想在安卓如何在sql中洗牌一列的数据?
num alph
------------
1 a
2 b
3 c
4 d
洗牌SQLite中alph
上click event
这是我的代码
public class MainActivity extends Activity {
SQLiteDatabase db;
String a,c;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
db=openOrCreateDatabase("dat", MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXISTS rk(num integer,alph char);");
db.execSQL("INSERT INTO rk VALUES('1','a');");
db.execSQL("INSERT INTO rk VALUES('2','b');");
db.execSQL("INSERT INTO rk VALUES('3','c');");
db.execSQL("INSERT INTO rk VALUES('4','d');");
db.execSQL("INSERT INTO rk VALUES('5','e');");
}
public void disp(View view){
EditText ed;
ed=(EditText)findViewById(R.id.editText1);
a=ed.getText().toString();
Cursor b=db.rawQuery("SELECT alph FROM rk WHERE num='a';",null);
//System.out.println(b.getString(0));
c=b.toString();
System.out.println("a2");
System.out.println(c);
Builder builder=new AlertDialog.Builder(MainActivity.this);
builder.setMessage(c);
AlertDialog alert=builder.create();
alert.show();
}
什么你的意思是洗牌'alph'?如果要显示在视图中混排的'alph'数据,则应该在视图层而不是数据库层执行此操作。 –
我想修改db中的数据... –