Solucionado (ver solução)
Solucionado
(ver solução)
7
respostas

Erro na execução: Unfortunately, CadastroCaelum has stopped.

11-17 19:14:42.905 3905-3905/? I/art: Not late-enabling -Xcheck:jni (already on)
11-17 19:14:43.087 3905-3905/? W/Zygote: Slow operation: 1027ms so far, now at zygoteConnection.runOnce: postForkAndSpecialize
11-17 19:14:44.795 3905-3912/br.com.the7web.cadastro W/art: Suspending all threads took: 119.654ms
11-17 19:14:45.159 3905-3912/br.com.the7web.cadastro W/art: Suspending all threads took: 5.004ms
11-17 19:14:46.295 3905-3905/br.com.the7web.cadastro D/AndroidRuntime: Shutting down VM
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime: FATAL EXCEPTION: main
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime: Process: br.com.the7web.cadastro, PID: 3905
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {br.com.the7web.cadastro/br.com.the7web.cadastro.ListaAlunosActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2989)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3020)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.access$800(ActivityThread.java:151)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5257)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:  Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.widget.ArrayAdapter.getCount(ArrayAdapter.java:330)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.widget.ListView.setAdapter(ListView.java:487)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at br.com.the7web.cadastro.ListaAlunosActivity.carregaLista(ListaAlunosActivity.java:71)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at br.com.the7web.cadastro.ListaAlunosActivity.onResume(ListaAlunosActivity.java:64)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1257)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.Activity.performResume(Activity.java:6076)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2978)
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3020) 
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102) 
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135) 
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5257) 
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method) 
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372) 
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
11-17 19:14:46.373 3905-3905/br.com.the7web.cadastro E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
11-17 19:14:46.424 3905-3917/br.com.the7web.cadastro W/art: Suspending all threads took: 7.383ms
11-17 19:14:46.484 3905-3917/br.com.the7web.cadastro I/art: Background sticky concurrent mark sweep GC freed 3149(279KB) AllocSpace objects, 0(0B) LOS objects, 28% free, 796KB/1117KB, paused 11.378ms total 263.643ms
11-17 19:14:50.570 3905-3905/br.com.the7web.cadastro I/Process: Sending signal. PID: 3905 SIG: 9
7 respostas

José, caso tenha mudado alguma coisa na sua ListaAlunosActivity, posta aqui. Caso não eu uso a do outro tópico.

Posta também o código AlunoDAO, por favor.

Abraço!

// ListaAlunosActivity

package br.com.the7web.cadastro;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import java.io.Serializable;
import java.util.List;

/**
 * Created by J r n i n on 16/11/2015.
 */
public class ListaAlunosActivity extends AppCompatActivity {
    private ListView lista;
    private Aluno aluno;



    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.listagem_alunos);


        lista= (ListView) findViewById(R.id.lista);
        registerForContextMenu(lista);

        lista.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> adapter, View view, int posicao, long id) {
                Aluno alunoParaSerAlterado = (Aluno) adapter.getItemAtPosition(posicao);

               Intent irParaFormulario = new Intent(ListaAlunosActivity.this, br.com.the7web.cadastro.FormularioActivity.class);
                irParaFormulario.putExtra("alunoSelecionado", (Serializable) alunoParaSerAlterado);

                startActivity(irParaFormulario);
            }
        });
        lista.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

            @Override
            public boolean onItemLongClick(AdapterView<?> adapter, View view, int posicao, long id) {
                aluno = (Aluno) adapter.getItemAtPosition(posicao);
                return false;
            }
        });

    }
    @Override
    protected void onResume(){
        super.onResume();
        carregaLista();
    }

    private void carregaLista() {
        AlunoDAO dao = new AlunoDAO(this);
        List<Aluno> alunos = dao.getLista();
        ArrayAdapter<Aluno> adapter = new ArrayAdapter<Aluno>(this, android.R.layout.simple_list_item_1, alunos);
        lista.setAdapter(adapter);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_lista_alunos, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()){
            case R.id.novo:
                Intent irParaFormulario = new Intent(this, br.com.the7web.cadastro.FormularioActivity.class);
                startActivity(irParaFormulario);
                break;

            default:
                break;
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
        menu.add("Ligar");
        menu.add("Enviar SMS");
        menu.add("Achar no Mapa");
        menu.add("Navegar no Site");
        MenuItem deletar = menu.add("Deletar");
        deletar.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                AlunoDAO dao = new AlunoDAO(ListaAlunosActivity.this);
                dao.deletar(aluno);
                dao.close();

                carregaLista();
                return false;
            }
        });
        menu.add("Enviar E-mail");

        super.onCreateContextMenu(menu, v, menuInfo);
    }
}




// AlunoDAO

package br.com.the7web.cadastro;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by J r n i n on 17/11/2015.
 */
class AlunoDAO extends SQLiteOpenHelper {
    private static final String DATABASE = "NomeDoBanco";
    private static final int VERSAO = 2;
    private static final String TABELA = "Alunos";


    public AlunoDAO(Context ctx){
        super(ctx, DATABASE, null, VERSAO);

    }


    @Override
    public void onCreate(SQLiteDatabase database) {
       String sql =  "CREATE TABLE " + TABELA + " ("
                + "id INTEGER PRIMARY KEY, "
                + "nome TEXT UNIQUE NOT NULL, "
                + "telefone TEXT, "
                + "endereco TEXT, "
                + "site TEXT, "
                + "nota REAL, "
                + "caminhoFoto TEXT"
                + ");";
        database.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
        String sql = "DROP TABLE IF EXISTS " + TABELA;
        database.execSQL(sql);
        onCreate(database);
    }
    public void salvar(Aluno aluno){
        ContentValues values = new ContentValues();
        values.put("nome", aluno.getNome());
        values.put("endereco", aluno.getEndereco());
        values.put("site", aluno.getSite());
        values.put("telefone", aluno.getTelefone());
        values.put("nota", aluno.getNota());
        values.put("caminhoFoto", aluno.getCaminhoFoto());

        getWritableDatabase().insert("Alunos", null, values);


    }

    public void insere(Aluno aluno) {
//informando para o bd onde queremos colocar cada informação nas colunas do bd
        ContentValues cv = new ContentValues();
        cv.put("nome", aluno.getNome());
        cv.put("telefone", aluno.getTelefone());
        cv.put("endereco", aluno.getEndereco());
        cv.put("site", aluno.getSite());
        cv.put("nota", aluno.getNota());
        cv.put("caminhoFoto", aluno.getCaminhoFoto());

        getWritableDatabase().insert(TABELA, null, cv);

    }

    public List<Aluno> getLista() {
        List<Aluno> alunos = new ArrayList<Aluno>();

        String sql = "SELECT * FROM " + TABELA + ";";
        Cursor c = getReadableDatabase().rawQuery(sql, null);

        while (c.moveToNext()){
            Aluno aluno = new Aluno();
            aluno.setId(c.getLong(c.getColumnIndex("id")));
            aluno.setNome(c.getString(c.getColumnIndex("nome")));
            aluno.setTelefone(c.getString(c.getColumnIndex("telefone")));
            aluno.setEndereco(c.getString(c.getColumnIndex("endereco")));
            aluno.setSite(c.getString(c.getColumnIndex("site")));
            aluno.setNota(c.getDouble(c.getColumnIndex("nota")));
            aluno.setCaminhoFoto(c.getString(c.getColumnIndex("caminhoFoto")));

            alunos.add(aluno);
        }
        return null;
    }

    public void deletar(Aluno aluno) {
        String[] args = {aluno.getId().toString()};
        getWritableDatabase().delete("Alunos", "id=?", args );
    }

    public void atualizar(Aluno aluno) {
        ContentValues values = new ContentValues();
        values.put("nome", aluno.getNome());
        values.put("endereco", aluno.getEndereco());
        values.put("site", aluno.getSite());
        values.put("telefone", aluno.getTelefone());
        values.put("nota", aluno.getNota());
        values.put("caminhoFoto", aluno.getCaminhoFoto());

        String[] args = {aluno.getId().toString()};
        getWritableDatabase().update("Alunos", values, "id=?", args);

    }
}
solução!

José,

O seu método getLista() do AlunoDao está retornando nulo. Você deve retornar a lista de alunos.

public List<Aluno> getLista() {
        List<Aluno> alunos = new ArrayList<Aluno>();

        String sql = "SELECT * FROM " + TABELA + ";";
        Cursor c = getReadableDatabase().rawQuery(sql, null);

        while (c.moveToNext()){
            Aluno aluno = new Aluno();
            aluno.setId(c.getLong(c.getColumnIndex("id")));
            aluno.setNome(c.getString(c.getColumnIndex("nome")));
            aluno.setTelefone(c.getString(c.getColumnIndex("telefone")));
            aluno.setEndereco(c.getString(c.getColumnIndex("endereco")));
            aluno.setSite(c.getString(c.getColumnIndex("site")));
            aluno.setNota(c.getDouble(c.getColumnIndex("nota")));
            aluno.setCaminhoFoto(c.getString(c.getColumnIndex("caminhoFoto")));

            alunos.add(aluno);
        }
        return null;
    }

Sempre que der NullPointerException quer dizer que tem algum lugar nulo :)

Abraço!

Joviane, obrigado pela ajuda, arrumei essa parte, olha como ficou:

//  AlunoDAO
 public List<Aluno> getLista() {
        List<Aluno> alunos = new ArrayList<Aluno>();

        String sql = "SELECT * FROM " + TABELA + ";";
        Cursor c = getReadableDatabase().rawQuery(sql, null);

        while (c.moveToNext()){
            Aluno aluno = new Aluno();
            aluno.setId(c.getLong(c.getColumnIndex("id")));
            aluno.setNome(c.getString(c.getColumnIndex("nome")));
            aluno.setTelefone(c.getString(c.getColumnIndex("telefone")));
            aluno.setEndereco(c.getString(c.getColumnIndex("endereco")));
            aluno.setSite(c.getString(c.getColumnIndex("site")));
            aluno.setNota(c.getDouble(c.getColumnIndex("nota")));
            aluno.setCaminhoFoto(c.getString(c.getColumnIndex("caminhoFoto")));

            alunos.add(aluno);
        }
        return alunos;
    }

Olha o LogCat:

// LogCat

11-18 17:35:15.270 1394-1394/br.com.the7web.cadastro I/art: Not late-enabling -Xcheck:jni (already on)
11-18 17:35:15.910 1394-1394/br.com.the7web.cadastro W/Zygote: Slow operation: 1251ms so far, now at Zygote.postForkCommon
11-18 17:35:15.911 1394-1394/br.com.the7web.cadastro W/Zygote: Slow operation: 1289ms so far, now at zygoteConnection.runOnce: postForkAndSpecialize
11-18 17:35:18.474 1394-1403/br.com.the7web.cadastro W/art: Suspending all threads took: 135.234ms
11-18 17:35:18.921 1394-1403/br.com.the7web.cadastro W/art: Suspending all threads took: 78.960ms
11-18 17:35:20.417 1394-1403/br.com.the7web.cadastro W/art: Suspending all threads took: 61.672ms
11-18 17:35:20.943 1394-1403/br.com.the7web.cadastro W/art: Suspending all threads took: 52.537ms
11-18 17:35:21.369 1394-1403/br.com.the7web.cadastro W/art: Suspending all threads took: 23.768ms
11-18 17:35:23.168 1394-1403/br.com.the7web.cadastro W/art: Suspending all threads took: 324.026ms
11-18 17:35:23.209 1394-1408/br.com.the7web.cadastro W/art: Suspending all threads took: 21.184ms
11-18 17:35:23.257 1394-1408/br.com.the7web.cadastro I/art: Background sticky concurrent mark sweep GC freed 2984(239KB) AllocSpace objects, 0(0B) LOS objects, 32% free, 750KB/1117KB, paused 23.227ms total 481.598ms
11-18 17:35:23.278 1394-1408/br.com.the7web.cadastro W/art: Suspending all threads took: 18.927ms
11-18 17:35:23.377 1394-1403/br.com.the7web.cadastro W/art: Suspending all threads took: 31.851ms
11-18 17:35:23.384 1394-1394/br.com.the7web.cadastro D/AndroidRuntime: Shutting down VM
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime: FATAL EXCEPTION: main
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime: Process: br.com.the7web.cadastro, PID: 1394
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {br.com.the7web.cadastro/br.com.the7web.cadastro.ListaAlunosActivity}: android.database.sqlite.SQLiteException: Can't downgrade database from version 2 to 1
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2989)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3020)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.access$800(ActivityThread.java:151)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5257)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:  Caused by: android.database.sqlite.SQLiteException: Can't downgrade database from version 2 to 1
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.database.sqlite.SQLiteOpenHelper.onDowngrade(SQLiteOpenHelper.java:360)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:254)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at br.com.the7web.cadastro.AlunoDAO.getLista(AlunoDAO.java:79)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at br.com.the7web.cadastro.ListaAlunosActivity.carregaLista(ListaAlunosActivity.java:69)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at br.com.the7web.cadastro.ListaAlunosActivity.onResume(ListaAlunosActivity.java:64)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1257)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.Activity.performResume(Activity.java:6076)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2978)
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3020) 
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395) 
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102) 
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135) 
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5257) 
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method) 
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372) 
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
11-18 17:35:23.508 1394-1394/br.com.the7web.cadastro E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
11-18 17:35:37.607 1394-1403/br.com.the7web.cadastro W/art: Suspending all threads took: 230.516ms
11-18 17:35:55.706 1394-1403/br.com.the7web.cadastro W/art: Suspending all threads took: 286.807ms
11-18 17:37:05.813 1394-1403/br.com.the7web.cadastro W/art: Suspending all threads took: 166.392ms

Oi Jose, uma das causas pra mensagem Can't downgrade database from version 2 to 1 é que o arquivo de banco na aplicação está com a versao 2, no caso, e você está passando a versão 1.

Acredito que você resolve isso de uma forma simples. Primeiraente, pode deixar a versao do banco em 1 mesmo:

private static final int VERSAO = 1;

Depois, já que é uma aplicação de teste, desinstala a aplicação no dispositivo, ou limpa os dados. De preferência, desinstala logo!

Para impar os dados, você pode ir em Configurações -> Aplicativos -> Clica no aplicativo -> Limpar dados..

Depois disso, tenta rodar a aplicação.

Testa e vê se funciona?

Abraço.

Lucas deu certo cara, obrigado, alterei a VERSAO = 1; e Desinstalei o app, vou concluir a Aula 6 agora, vlw!

Opa Jose, que bom que funcionou!

Nesse caso, encerra o tópico marcando a resposta da Joviane como correta, por favor?

Qualquer dúvida é só abrir outro tópico no fórum. :)

Abraço.