01


SUBMITTED BY: Guest

DATE: Nov. 10, 2013, 4:07 p.m.

FORMAT: Text only

SIZE: 5.6 kB

HITS: 4212

  1. public void onCreate(SQLiteDatabase db) {
  2. String CREATE_Order_Inner_TABLE = "CREATE TABLE " + TABLE_Order_Inner_Table + "("
  3. + Order_id + " AUTO_INCREMENT,"
  4. + Order_Date + " TEXT,"
  5. + Order_Time + " TEXT,"
  6. + Order_Total_Price + " TEXT"
  7. + ")";
  8. db.execSQL(CREATE_Order_Inner_TABLE);
  9. }
  10. // Creating Tables
  11. public void onCreate_previous_order(SQLiteDatabase db) {
  12. }
  13. // Upgrading database
  14. @Override
  15. public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  16. // Drop older table if existed
  17. db.execSQL("DROP TABLE IF EXISTS " + TABLE_Order_Inner_Table);
  18. // Create tables again
  19. onCreate(db);
  20. }
  21. /**
  22. * Storing user details in database
  23. * */
  24. public int addInnerOrder(String Date, String time, String totalprice) {
  25. SQLiteDatabase db = this.getWritableDatabase();
  26. ContentValues values = new ContentValues();
  27. values.put(Order_Date, Date); // Name
  28. values.put(Order_Time, time); // Email
  29. values.put(Order_Total_Price,totalprice ); // Email
  30. // Inserting Row
  31. int id = (int) db.insert(TABLE_Order_Inner_Table, null, values);
  32. db.close(); // Closing database connection
  33. return id;
  34. }
  35. /**
  36. * Getting user data from database
  37. * */
  38. public ArrayList<HashMap<String, Object>> getHistroyDetails(){
  39. HashMap<String,String> user = new HashMap<String,String>();
  40. String selectQuery = "SELECT * FROM " + TABLE_Order_Inner_Table;
  41. SQLiteDatabase db = this.getReadableDatabase();
  42. Cursor cursor = db.rawQuery(selectQuery, null);
  43. // Move to first row
  44. cursor.moveToFirst();
  45. // if(cursor.getCount() > 0){
  46. while(!cursor.isAfterLast())
  47. {
  48. HashMap<String, Object> map = new HashMap<String, Object>();
  49. DataHolderHistroy obj=new DataHolderHistroy();
  50. android.util.Log.i("cursor.getInt(cursor.getColumnIndex(Order_id))"," "+ cursor.getInt(cursor.getColumnIndex(Order_id)));
  51. obj.setData(cursor.getInt(cursor.getColumnIndex(Order_id)),cursor.getString(cursor.getColumnIndex(Order_Date)),cursor.getString(cursor.getColumnIndex(Order_Total_Price)),cursor.getString(cursor.getColumnIndex(Order_Time)));
  52. android.util.Log.i("cursor.getInt(22222222222"," "+ cursor.getString(cursor.getColumnIndex(Order_id)));
  53. android.util.Log.i("cursor.gets(getStringgetString", cursor.getString(cursor.getColumnIndex(Order_Date)));
  54. map.put(ITEMTITLEOrder, obj);
  55. // adding HashList to ArrayList
  56. OrdersList.add(map);
  57. cursor.moveToNext();
  58. // }
  59. }
  60. cursor.close();
  61. db.close();
  62. // return user
  63. return OrdersList;
  64. }
  65. public class DataHolderHistroy
  66. {
  67. int Id;
  68. String Date;
  69. String totalPrice;
  70. String time;
  71. public void setData(int id,String date,String totalprice, String time)
  72. {
  73. this.Id=id;
  74. this.Date=date;
  75. this.totalPrice=totalprice;
  76. this.time=time;
  77. }
  78. public int Get_id()
  79. {return Id;}
  80. public String GetDate()
  81. {return Date;}
  82. public String Getprice()
  83. {return totalPrice;}
  84. public String Gettime()
  85. {return time;}
  86. }
  87. }
  88. 10-01 17:03:49.820: I/cursor.getInt(cursor.getColumnIndex(Order_id))(23142): 0
  89. 10-01 17:03:49.820: I/cursor.getInt(22222222222(23142): null
  90. 10-01 17:03:49.820: I/cursor.gets(getStringgetString(23142): 01-Oct-2013
  91. DataHolderHistroy obj=new DataHolderHistroy();
  92. android.util.Log.i("cursor.getInt(cursor.getColumnIndex(Order_id))"," "+ cursor.getInt(cursor.getColumnIndex(Order_id)));
  93. obj.setData(cursor.getInt(cursor.getColumnIndex(Order_id)),
  94. cursor.getString(cursor.getColumnIndex(Order_Date)),cursor.getString(cursor.getColumnIndex(Order_Total_Price)),cursor.getString(cursor.getColumnIndex(Order_Time)));
  95. android.util.Log.i
  96. ("cursor.getInt(22222222222"," "+ cursor.getString(cursor.getColumnIndex(Order_id)));
  97. android.util.Log.i("cursor.gets(getStringgetString", cursor.getString(cursor.getColumnIndex(Order_Date)));
  98. android.util.Log.i("cursor.getInt(22222222222"," "+ cursor.getInt(cursor.getColumnIndex(Order_id)));

comments powered by Disqus