You can make it simpler by the use of string's split function.
Follow these steps:
1)Make a large string of timeslots separated by unique character
2)Pass the string to another activity
3)Fetch the string and split it into array
First Activity
SQLiteDatabase db = openOrCreateDatabase("MyDB",MODE_PRIVATE, null);
Cursor c=db.rawQuery("SELECT timeslots FROM medprofile",null);
String timeslots="";
int i=0;
while(c.moveToNext())
{
String uname = c.getString(c.getColumnIndex("timeslots"));
timeslots+=uname+"#";
Toast.makeText(getApplicationContext(), uname, Toast.LENGTH_SHORT).show();
}
Intent in=new Intent(MainActivity.this,profileview.class);
in.putExtra("timeslots",timeslots);
startActivity(in);
}
Second Activity
Add this code in onCreate method of second activity
Bundle extras=getIntent().getExtras();
String[] timeslots=extras.getString("timeslots").split("#");