I'm having the following problem.
Error in Android: no such table: CADASTRO (code 1):, while compiling: INSERT INTO CADASTRO(NOME) VALUES (?)
I'm trying to manually enter a value in the database and test it.
CODE:
package com.bytemeta.bytenota.dominio;
import android.content.ContentValues;
import android.content.Context;
import android.database.*;
import android.database.Cursor;
import android.database.sqlite.*;
import android.widget.ArrayAdapter;
import android.widget.*;
public class RepositorioCadastro {
private SQLiteDatabase conn;
public RepositorioCadastro(SQLiteDatabase conn) {
this.conn = conn;
}
public void testeInserirCadastro() {
for (int i = 0; i < 10; i++) {
ContentValues values = new ContentValues();
values.put("NOME","THIAGO");
conn.insertOrThrow("CADASTRO", null, values);
}
}
public ArrayAdapter<String> buscaCadastro(Context context) {
ArrayAdapter<String> adpCadastro = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1);
Cursor cursor = conn.query("BYTENOTA_DB", null, null, null, null, null, null, null);
if (cursor.getCount() > 0) {
cursor.moveToFirst();
do {
String NOME = cursor.getString(1);
adpCadastro.add(NOME);
} while (cursor.moveToNext());
}
return adpCadastro;
}
}
Aucun commentaire:
Enregistrer un commentaire