I am inserting data in sqlite about 10 lakhs data and i have used asynctask to insert the data in sqlite now after inserting some records i want to show some data from database in my listview how to retrieve some data from database. Because it takes too much time to insert in database and till insertion i have to show some inserted data from database. Is it possible? I have already inserted data in sqlite database. Now i am having trouble to retrieve data while inserting.
public class inserinrss extends AsyncTask<Void, Void, Void>{
public inserinrss(String mtitle,String mdescription,String mpubdate,String mguid,String mdc_date,byte[] mbarrbuf){
title = mtitle;
dec1 = mdescription;
pubdate = mpubdate;
guid = mguid;
dc_date = mdc_date;
barrbuf = mbarrbuf;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... params) {
mDbHelper.openDataBase();
mDbHelper.Insertrss(mDbHelper.myDataBase,
title, dec1, pubdate, guid, dc_date,
barrbuf);
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
List<RssItem> items1 = new ArrayList<RssItem>();
if (isInternet()) {
progressBar.setVisibility(View.GONE);
mDbHelper.openDataBase();
Cursor AllFriends = mDbHelper.getFriends();
AllFriends.moveToFirst();
while (!AllFriends.isAfterLast()) {
String title1 = AllFriends.getString(0);
String desc = AllFriends.getString(1);
String pubdate1 = AllFriends.getString(2);
String guid1 = AllFriends.getString(3);
String dcdate = AllFriends.getString(4);
byte[] image = AllFriends.getBlob(5);
RssItem item = new RssItem(title1, desc, pubdate1, guid1,
dcdate);
item.setImage(image);
item.setDescription(desc);
items1.add(item);
AllFriends.moveToNext();
}
RssAdapter adapter = new RssAdapter(getActivity(), items1);
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
}
}
And i am calling this asynctask as follow
inserinrss ind = new inserinrss(title, dec1, pubdate, guid, dc_date, barrbuf.toByteArray());
ind.execute();
Thanks
Aucun commentaire:
Enregistrer un commentaire