lycastos
lycastos

Reputation: 3

android SQLite method malfunction(?!?!)

I face this weird problem with SQLite; I have this dynamically generated from db, checkbox list... when I first open my app it doesn't load properly in my Linear Layout, actually the sqlite query doesn't return any string! But when I change fragment (from my first pane to map pane) and go back (to my first pane where I should see my checkbox list)everything works as it supposed to work and checkbox list appears! My logcat doesn't show any exception or anything suspicious...

this is my method:

        private int setCheckboxes(){
SQLiteDatabase database = DatabaseManager.getInstance().openDatabase();
        database.setLocale(Locale.getDefault());

            String queryRoutes="SELECT * FROM"+tableRoute;
            Cursor dataRoutes = database.rawQuery(queryRoutes, null);
            ArrayList<String> routesStrings = new returnMapStuff().getRoutesArray(dataRoutes);
    DatabaseManager.getInstance().closeDatabase();
            routesStrings.size();
            try{
                CheckBox cb;
                for (int i = 0; i < routesStrings.size(); i++) {
                    cb = new CheckBox(context);
                    cb.setText(routesStrings.get(i));
                    cb.setId(i);
                    ll.addView(cb);
                 }
            }catch (Exception e){e.printStackTrace();}

            return routesStrings.size();
}

and this is how i call it:

View view = inflater.inflate(R.layout.fragment_main, container, false);
ll = (LinearLayout) view.findViewById(R.id.CheckboxLL);
int howManyCheckboxes =setCheckboxes();


this is my logcat with a few log.i():
04-01 09:22:40.883    2412-2412/pack.androidmap I/POSA CHECKBOXES?﹕ 0

//return value(setCheckboxes()) first then it runs  (inside)returnMapstuff():


04-01 09:23:00.451    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ paralia
04-01 09:23:00.451    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ petalo
04-01 09:23:00.451    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ partali
04-01 09:23:00.451    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ ateik
04-01 09:23:00.451    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ pagni
04-01 09:23:00.451    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ λύκαστος
04-01 09:23:00.451    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ smallville
04-01 09:23:00.451    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ αλί καρνέησον
04-01 09:23:00.451    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ καμπαμαρούν

// but when I press back (first returnMapstuff()):

04-01 09:23:04.843    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ paralia
04-01 09:23:04.843    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ petalo
04-01 09:23:04.843    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ partali
04-01 09:23:04.843    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ ateik
04-01 09:23:04.843    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ pagni
04-01 09:23:04.843    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ λύκαστος
04-01 09:23:04.843    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ smallville
04-01 09:23:04.843    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ αλί καρνέησον
04-01 09:23:04.843    2412-2412/pack.androidmap I/POSA route mesa mapstuff?﹕ καμπαμαρούν

//then return value of setCheckboxes()
04-01 09:23:04.847    2412-2412/pack.androidmap I/POSA CHECKBOXES?﹕ 9

How is this possible?

Upvotes: 0

Views: 36

Answers (1)

Phant&#244;maxx
Phant&#244;maxx

Reputation: 38098

actually the sqlite query doesn't return any string!

You miss a space here

String queryRoutes="SELECT * FROM"+tableRoute;

It must be

String queryRoutes="SELECT * FROM "+tableRoute;

Upvotes: 2

Related Questions