I am extracting a database using query, what is the best practice to store the data temporarily. Currently i am using ArrayList to hold the data extracted, but i am thinking that might not be best design practice.
Thanks
Cursor cur5 = database2.rawQuery("select ID from Quote where EmoticonID=? and SubCategoryID=?" ,new String [] {Integer.toString(gcid), Integer.toString(scid)});
if(cur5.getCount()==0){
Log.i("TAG Screen3", "No Quotes ID found for Particular ID");
if (helper2 != null) {
helper2.close();
}
if (database2 != null) {
database2.close();
}
}else{
cur5.moveToFirst();
do {
quoteid.add(Integer.parseInt(cur5.getString(0)));
Log.i("TAG Screen3 Quote ID", (cur5.getString(0)));
} while (cur5.moveToNext());
if(cur5 != null){
cur5.close();
}
if (helper2 != null) {
helper2.close();
}
if (database2 != null) {
database2.close();
}
}
Well if you already have a database to get the data from, why not using that database as temp store. Just get the data from the database when you need it an skip the temporary storage.
If you still want to store it locally on your phone I suggest a local sqlite database for huge objects or POJO’s. If you have primitive types of key-value pairs you should use SharedPreferences.
For more information see http://developer.android.com/guide/topics/data/data-storage.html.
Or give us some information about your data and what you intend to do:) That might help us in helping you 😉