I'm trying to create list of arrays, dynamic in size, add elements and iterate through them when I finish. Currently my code is:
String activities = "SELECT DISTINCT phoneactivity from ContextTable030313";
ArrayList<String> myActivities = new ArrayList();
Cursor cursor2 = db.rawQuery(activities, null);
// looping through all rows and adding to list
if (cursor2.moveToFirst()) {
do {
myActivities.add(cursor.getString(cursor2.getColumnIndex("ts")));
} while (cursor2.moveToNext());
}
Yet it fails to run in the do loop. I believe I am declaring something incorrectly and I get the following warnings:
- ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized
- Avoid object allocations during draw/layout operations (preallocate and reuse instead)
- Type safety: The expression of type ArrayList needs unchecked conversion to conform to
ArrayList<String>
yet I do not understand why this does not work.
cursor.getString(cursor2.getColumnIndex("ts"))in your console what exactly printing this line.