Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. public String[] getNames (int a, int b) {
  2.  
  3. String[] names = new String[] {};
  4.  
  5. String selectQuery = "SELECT * FROM " + TABLE_NAME
  6. + " WHERE " + KEY_ONE + " = ? AND " + KEY_TWO + " = ?";
  7.  
  8.  
  9. SQLiteDatabase db = this.getWritableDatabase();
  10. Cursor cursor = db.rawQuery(selectQuery, new String[]{String.valueOf(a), String.valueOf(b)});
  11.  
  12. if (cursor.moveToFirst()) {
  13.  
  14. int i = 0;
  15.  
  16. do {
  17. Data myData = new Data();
  18.  
  19. names [i] = cursor.getString(1); //Names in cursor
  20.  
  21. ++i;
  22.  
  23. } while (cursor.moveToNext());
  24.  
  25. }
  26. return names;
  27. }
  28.  
  29. values = db.getNames (1, 1);
  30.  
  31. String[] names = new String[] {};
  32.  
  33. names [i] = cursor.getString(1); //Names in cursor
  34.  
  35. List<String> names = new ArrayList<String>();
  36.  
  37. names.add(cursor.getString(1));
  38.  
  39. String[] arr = new String[names.size()];
  40. names.toArray(arr);
  41. return arr;
  42.  
  43. String[] arrRecords = names.toArray(new String[names.size()]);
  44.  
  45. String[] names = new String[] {}; //no size
  46.  
  47. names [i] = cursor.getString(1); //it can work?
  48.  
  49. List<String> names = new ArrayList<String>(); //declare
  50.  
  51. names.add(<column-val>); //add column value to list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement