Saving ArrayLists in SQLite databases

前端 未结 6 2252
傲寒
傲寒 2020-11-30 03:42

So I want to save an ordered set of double values, and I want to be able to insert, retrieve or delete any value from this easily. As of such, I\'m using a an ArrayList, whe

6条回答
  •  眼角桃花
    2020-11-30 04:03

    Create a dbHelper class which has an inner class and pretty much whatever the notepad tutorial says. The class must be having an insertion method somthing like this :-

    public long insertRows(ContentValues values, String tableName) {
        long val = myDatabase.insert(tableName, null, values);
        return val;
    }
    

    This method will then add values into the table row. After that you can call this method from your main activity and since you are using cursor i believe you will call the method in a for loop

    for(i=0;list.length();i++) or may be its list.size :P

    {

    // Call the method here

    }

    and keep adding value in the database by calling the method in for loop

提交回复
热议问题