我刚买了三星Galaxy S3,我也有HTC Desire S.我差不多完成了我的应用程序,它在HTC Desire S上运行得很好。问题在于我的S3 - 执行任务时出现内存错误。它是第一次通过,但每次下一次执行都会因为错误-12而导致应用程序崩溃(无法分配大小为2097152的cursorWindow(Databases / baza ....)
我的主题:
private class nalozi_statistiko_igralca extends AsyncTask<Void, Integer, Void> {
protected Void doInBackground( Void... ignoredParams ) {
publishProgress();
vpisi_statistiko_igralca_update();
cursor_statistika_igralca_tocke = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_domaci_kopija+ " ORDER BY tocke DESC", null);
cursor_statistika_igralca_tocke_gosti = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_gosti_kopija+" ORDER BY tocke DESC", null);
cursor_statistika_igralca_asistence = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_domaci_kopija+ " ORDER BY asistence DESC", null);
cursor_statistika_igralca_asistence_gosti = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_gosti_kopija+ " ORDER BY asistence DESC", null);
cursor_statistika_igralca_obrambni_skoki = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_domaci_kopija+ " ORDER BY defensive_rebounds DESC", null);
cursor_statistika_igralca_obrambni_skoki_gosti = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_gosti_kopija+ " ORDER BY defensive_rebounds DESC", null);
cursor_statistika_igralca_napadalni_skoki = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_domaci_kopija+ " ORDER BY offensive_rebounds DESC", null);
cursor_statistika_igralca_napadalni_skoki_gosti = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_gosti_kopija+ " ORDER BY offensive_rebounds DESC", null);
cursor_statistika_igralca_ukradene_zoge = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_domaci_kopija+ " ORDER BY steals DESC", null);
cursor_statistika_igralca_ukradene_zoge_gosti = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_gosti_kopija+ " ORDER BY steals DESC", null);
cursor_statistika_igralca_blokade = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_domaci_kopija+ " ORDER BY blocks DESC", null);
cursor_statistika_igralca_blokade_gosti = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_gosti_kopija+ " ORDER BY blocks DESC", null);
cursor_statistika_igralca_izgubljene_zoge = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_domaci_kopija+ " ORDER BY turnovers DESC", null);
cursor_statistika_igralca_izgubljene_zoge_gosti = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_gosti_kopija+ " ORDER BY turnovers DESC", null);
cursor_statistika_igralca_osebne = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_domaci_kopija+ " ORDER BY fouls DESC", null);
cursor_statistika_igralca_osebne_gosti = baza5.rawQuery("SELECT * FROM player_stats" +
" WHERE id_seznam_iger LIKE "+id_seznam_iger+ " AND id_ekipe LIKE "+ id_izbrane_ekipe_gosti_kopija+ " ORDER BY fouls DESC", null);
return null;
}
protected void onPostExecute( Void array )
{
if(nalozi_statistiko_igralca_ali_upload==0)
{
pokazi_statistiko_igralca(view);
pokazi_statistiko_igralca_tocke2(view);
}
if(nalozi_statistiko_igralca_ali_upload==1)
{
naredi_pdf_izvrsi(view);
}
if(nalozi_statistiko_igralca_ali_upload==2)
{
pokazi_mvp_domaci(domaci_top_efficiency_id);
}
if(nalozi_statistiko_igralca_ali_upload==3)
{
pokazi_mvp_gosti(gosti_top_efficiency_id);
}
}
protected void onProgressUpdate(Integer... values)
{
Context context = getApplicationContext();
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, getString(R.string.toast_loading), duration);
toast.show();
}
}
public void vpisi_statistiko_igralca_update()
{
Cursor cursor_ekipa_domaci;
//list_home = (ListView) findViewById (R.id.list_home);
//cursor2 = baza5.query("igralci", null, null, null, null, null,"_id" + " ASC");
cursor_ekipa_domaci = baza5.query("igralci_kopija",null,
"id_ekipe like " + id_izbrane_ekipe_domaci_kopija,
null, null, null, null);
while (cursor_ekipa_domaci.moveToNext())
{
String a=cursor_ekipa_domaci.getString(0);
update_statistiko_igralca((Integer.valueOf(a)),
cursor_ekipa_domaci.getString(1),
cursor_ekipa_domaci.getString(2));
}
Cursor cursor_ekipa_gosti;
//list_home = (ListView) findViewById (R.id.list_home);
//cursor2 = baza5.query("igralci", null, null, null, null, null,"_id" + " ASC");
cursor_ekipa_gosti = baza5.query("igralci_kopija",null,
"id_ekipe like " + id_izbrane_ekipe_gosti_kopija,
null, null, null, null);
while (cursor_ekipa_gosti.moveToNext())
{
String a=cursor_ekipa_gosti.getString(0);
update_statistiko_igralca((Integer.valueOf(a)),
cursor_ekipa_gosti.getString(1),
cursor_ekipa_gosti.getString(2));
}
}
繁重的工作是在“vpisi_statistiko_igralca_update”功能中完成的。我想知道Galaxy S3是否将数据保存在内存中,但HTC Desire S不会...
答案 0 :(得分:0)
我明白了!!
当我不再需要它时,我需要关闭我的游标。 (我需要关闭大约100个不同的游标)。
(cursor.close());