安卓应用程序在cursor.movetofirst之前冻结,没有显示错误

时间:2014-08-30 13:42:12

标签: android sqlite cursor android-cursor

我有这个应用程序正在查询sqlite数据库,我正在重用代码来获取数据,它正在为10多个查询工作,但这一个查询正在冻结我的应用程序,直到corsor.movetonext

当我通过SQLite数据库浏览器运行它时,查询正在运行,该数据库与我的手机上的数据库相同。

这是我的疑问:

ArrayList<HashMap<String, String>>hml = new ArrayList<HashMap<String, String>>();
String fetchdata="select Gest.Dep,time(Gest.Dep,'unixepoch') as DTE,mobileAT.db_desp,Rock.RockNo,Travel.TravelNo,RockTravel.TravelSequence,Turn.Line,Turn.Description,Gest.StopSequence,Gest.Arrival,TurnStop.HaltId,Stop.Description,Stop.StopNo,CAST(LinkDot.Latitude as REAL)/1000000 as Lat,CAST(LinkDot.Longitude as REAL)/1000000 as Lng from Cal\n" +
                "      \n" +
                "                inner join Rock on Rock.TimetableVersion=Cal.TimetableVersion\n" +
                "                inner join RockTravel on Rock.Id=RockTravel.RockId\n" +
                "                inner join Travel on Travel.TimetableVersion=Cal.TimetableVersion and Travel.Id=RockTravel.TravelId\n" +
                "                inner join Turn on Travel.TurnId= Turn.Id\n" +
                "                inner join LinkDot on Stop.Id = LinkDot.FromHaltId\n" +
                "                inner join Gest on Gest.TravelId=RockTravel.TravelId\n" +
                "                inner join TurnStop on TurnStop.TurnId=Turn.Id  and TurnStop.StopSequence=Gest.StopSequence\n" +
                "                inner join Stop on Stop.Id=TurnStop.HaltId\n" +
                "                inner join mobileAT on mobileAT.db_desp=\""+desp+"\"\n" +
                "                \n" +
                "where Rock.RockNo=mobileAT.db_way  and LinkDot.Distance=0 and LinkDot.ToHaltId=-1 and time(Gest.Dep,'unixepoch') between mobileAT.db_time_from and mobileAT.db_time_to\n" +
                "group by Gest.Dep order by Gest.Dep"

SQLiteDatabase sqLiteDatabase=this.getReadableDatabase();
        Cursor cursor=sqLiteDatabase.rawQuery(fetchdata, null);

        Log.d("MSG","outside loop");

        if(cursor.moveToFirst()){
            do
            {

Log.d("MSG","inside loop");

                HashMap<String, String> Hmap = new HashMap<String,String>();
                Hmap.put("1",cursor.getString(0));
                Hmap.put("2",cursor.getString(1));
                Hmap.put("3",cursor.getString(2));
                Hmap.put("4",cursor.getString(3));
                Hmap.put("5",cursor.getString(4));
                Hmap.put("6",cursor.getString(5));
                Hmap.put("7",cursor.getString(6));
                Hmap.put("8",cursor.getString(7));
                hml.add(Hmap);

} while (cursor.moveToNext());
        }else{
            Log.d("MSG","here atleast?");
        }
        cursor.close();
        Log.d("MSG","Im leaving");
        return hml;

我正在获取Log.d(“MSG”,“外部循环”)LOG但没有别的,我无法理解导致冻结的原因。

0 个答案:

没有答案