-1

I am building an application where the user can save some information into an sqlite database. What I now want to do is be able to get the data from the sqlite database and store each row in its own string.

Note There is only one column in the database.

4

1 に答える 1

1

したがって、アルゴリズムは難しくありません。作成Cursorしてループ内でデータを取得しList、たとえばに保存します。

したがって、このコードスニペットを試してください。

final String SELECT_QUERY = "Select column from Table";
List<String> data = new ArrayList<String>();
String member = null;
Cursor c = db.rawQuery(SELECT_QUERY, null);
if (c.getCount() > 0 && c.moveToFirst()) {
   do {
      member = new String(c.getString(0));
      data.add(member);
   }
   while (c.moveToNext());
}
于 2012-07-01T08:17:03.297 に答える