I have following code & want all the data in arraylist comes from sqlite database
import android.app.Activity;
public DataSingleton() {
visibleSections = new ArrayList<>();
visibleSections.add("Who We Are");
visibleSections.add("What We Do");
visibleSections.add("How Can You Help");
visibleSections.add("Take a Look");
visibleSections.add("In The News");
visibleSections.add("Get In Touch");
}
}
public static String query_select_all = "SELECT * FROM " + TABLENAME;
public ArrayList<model> DataSingleton()
{
ArrayList<visible_Model> visibleSections = new ArrayList<visible_Model>();
Cursor cursor = database_helper.rawQuery(query_select_all, null);
if (cursor.moveToFirst()) {
do {
visible_Model model = new visible_Model();
model.setMessage(cursor.getString(cursor
.getColumnIndex(COLUMN_FROM_MSG)));
visibleSections.add(model);
} while (cursor.moveToNext());
}
return visibleSections;
}
Here,In above I create model name as a visile_model and use setMessage method.at last I add that model into arraylist visibleSections
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.