Portal Android - Comunidade de Desenvolvedores Android
http://www.portalandroid.org/comunidade/

Erro crud
http://www.portalandroid.org/comunidade/viewtopic.php?f=2&t=31247
Página 1 de 1

Autor:  aleander [ 10 Jun 2018, 17:51 ]
Assunto do Tópico:  Erro crud

Minha pricipal duvida e na parte INSERT INTO respostasAguaCasa(id,acordar,valoragua,dormir) VALUES (?,?,?,?) at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)

06-10 18:40:39.547 3634-3634/com.example.aleander.ma_e E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering 06-10 18:40:53.657 3634-3634/com.example.aleander.ma_e E/EGL_emulation: tid 3634: eglSurfaceAttrib(1199): error 0x3009 (EGL_BAD_MATCH) 06-10 18:41:04.207 3634-3634/com.example.aleander.ma_e E/EGL_emulation: tid 3634: eglSurfaceAttrib(1199): error 0x3009 (EGL_BAD_MATCH) 06-10 18:41:09.257 3634-3634/com.example.aleander.ma_e E/EGL_emulation: tid 3634: eglSurfaceAttrib(1199): error 0x3009 (EGL_BAD_MATCH) 06-10 18:41:17.367 3634-3634/com.example.aleander.ma_e E/EGL_emulation: tid 3634: eglSurfaceAttrib(1199): error 0x3009 (EGL_BAD_MATCH) 06-10 18:41:19.497 3634-3634/com.example.aleander.ma_e E/EGL_emulation: tid 3634: eglSurfaceAttrib(1199): error 0x3009 (EGL_BAD_MATCH) 06-10 18:41:25.777 3634-3634/com.example.aleander.ma_e E/SQLiteLog: (1) table respostasAguaCasa has no column named acordar 06-10 18:41:25.997 3634-3634/com.example.aleander.ma_e E/SQLiteDatabase: Error inserting id=0 acordar=0 valoragua=214 dormir=0 android.database.sqlite.SQLiteException: table respostasAguaCasa has no column named acordar (code 1): , while compiling: INSERT INTO respostasAguaCasa(id,acordar,valoragua,dormir) VALUES (?,?,?,?) at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889) at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500) at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:58) at android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:31) at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1467) at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339) at com.example.aleander.ma_e.aguacasatodosmetodos.crud.crud.Update.addResposta(Update.java:17) at com.example.aleander.ma_e.aguacasatodosmetodos.crud.EscolhaAguaCasa.adicionarPessoa(EscolhaAguaCasa.java:171) at com.example.aleander.ma_e.aguacasatodosmetodos.crud.EscolhaAguaCasa.salvar(EscolhaAguaCasa.java:151) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:384) at android.view.View.performClick(View.java:4438) at android.view.View$PerformClick.run(View.java:18422) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) 06-10 18:42:41.587 3634-3634/com.example.aleander.ma_e E/EGL_emulation: tid 3634: eglSurfaceAttrib(1199): error 0x3009 (EGL_BAD_MATCH)

Crud

Create

public class Create {



public void createtable() {
SQLiteDatabase db = Maindb.getInstancia().getWritableDatabase();
String colunas = "(id INTEGER PRIMARY KEY , valoragua INTEGER ,
acordarhora INTERGER , dormirhora INTERGER , acordarminutos INTERGER ,
dormirminutos INTERGER )";
String query = "CREATE TABLE IF NOT EXISTS " + Maindb.TABELA + colunas;
db.execSQL(query);
Read

public class Read {
public ArrayList<RespostasAguaCasa> getLista() {
SQLiteDatabase db =
Maindb.getInstancia().getWritableDatabase();
String query = "SELECT * FROM " + Maindb.TABELA;
ArrayList<RespostasAguaCasa> lista = new ArrayList<>();

Cursor c = db.rawQuery(query, null);
if (c.moveToFirst()) {

do {
RespostasAguaCasa resp = new RespostasAguaCasa(c.getString(0));
resp.setId(c.getInt(1));
resp.setValoragua(c.getInt(2));
resp.setAcordarhora(c.getInt(3));
resp.setAcordarminu(c.getInt(4));
resp.setDormirhora(c.getInt(5));
resp.setDormirminu(c.getInt(6));
lista.add(resp);
}
while (c.moveToNext());
{
}


}
c.close();
return lista;
}
}

Update

public class Update {
public boolean addResposta(RespostasAguaCasa respostasAguaCasa){
SQLiteDatabase db = Maindb.getInstancia().getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put("id" , respostasAguaCasa.getId());
cv.put("valoragua" , respostasAguaCasa.getValoragua());
cv.put("acordar" , respostasAguaCasa.getAcordarhora());
cv.put("dormir" , respostasAguaCasa.getDormirhora());
return db.insert(Maindb.TABELA, null , cv)!= -1;
}

public boolean UpdateResposta(RespostasAguaCasa respostasAguaCasa){
SQLiteDatabase db = Maindb.getInstancia().getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put("valoragua" , respostasAguaCasa.getValoragua());
cv.put("acordar" , respostasAguaCasa.getAcordarhora());
cv.put("dormir" , respostasAguaCasa.getDormirhora());
String where = "id = '" + respostasAguaCasa.getId() + "'";


return db.update(Maindb.TABELA, cv, where, null) > 0;
}
}

Maindb

public class MainDB extends SQLiteOpenHelper {

private static String NOME_DB = "DB";
private static int VERSAO_DB = 1;
public static String TABELA_PESSOA = "TABELA_PESSOA";


private static MainDB instancia;


public static MainDB getInstancia() {
if (instancia == null) instancia = new MainDB();
return instancia;
}


private MainDB() {
super(MyApp.getContext(), NOME_DB, null, VERSAO_DB);
}


@Override
public void onCreate(SQLiteDatabase db) {

}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

}


@Override
public synchronized void close() {
instancia = null;
super.close();
}
}

public class Myapp extends Application {
private static Context mContext;


@Override
public void onCreate() {
mContext = getApplicationContext();
super.onCreate();
}

public static Context getContext() {
return mContext;
}
}

Página 1 de 1 Todos os Horários estão como UTC - 2 horas [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/