Using External Sqlite in the Assets folder with Fragment

1

I'm using an external sqlite database, in the assets folder.

Follow this template ( uploading-a-created-bank -externally ) and got access to the bank.

How much testing worked normally on my MainActivity, the problem I had was when I tried to use it with Fragment.

In my project I'm using fragments, and I'm not getting it to work.

Part of the code that is inside a Fragment;

    helper = new DatabaseHelper(getActivity(),null,1);
    db = helper.getDatabase();

    list = (ListView) rootView.findViewById(R.id.listalivro);
    Cursor cursor = db.query("livro", campos, null, null, null, null, null);
    SimpleCursorAdapter Madapter = new SimpleCursorAdapter(getActivity(),
        android.R.layout.simple_list_item_1,
        cursor,
        new String[] {"ver_livro","ver_capitulo"},
        new int[] {R.id.ver_livro,R.id.ver_capitulo }, 0);

    list.setAdapter(Madapter);
    list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

Remembering that this code worked when I created a new project without fragment, I put everything in MainActivity. It copies the database and opens normally. But in my project it does not work.

11-23 16: 17: 19.053: E / Trace (755): error opening trace file: No such file or directory

I have already made sure that the database is in the assets folder, there is no firewall or antivirus blocking access. Remembering that if I use without fragment it works without problems.

    
asked by anonymous 24.11.2014 / 17:21

0 answers