Skip to content

Commit df3f0f2

Browse files
committed
corrigindo update
1 parent a9c1892 commit df3f0f2

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

app/src/main/java/br/com/sql/HelperBD.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import com.simplesql.simplesql.config.SimpleSQL;
1010

11+
import java.sql.SQLException;
12+
1113
/**
1214
* Created by Lucas Nascimento on 18/09/2019
1315
* Copyright (c) 2019 GFX Consultoria
@@ -21,10 +23,23 @@ public HelperBD(@Nullable Context context) {
2123

2224
@Override
2325
public void onCreate(SQLiteDatabase sqLiteDatabase) {
26+
SimpleSQL simpleSQL = new SimpleSQL(this);
27+
try {
28+
simpleSQL.create(new Pessoa());
29+
} catch (SQLException e) {
30+
e.printStackTrace();
31+
}
32+
2433
}
2534

2635
@Override
2736
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
37+
SimpleSQL simpleSQL = new SimpleSQL(this);
38+
try {
39+
simpleSQL.deleteTable(new Pessoa());
40+
} catch (SQLException e) {
41+
e.printStackTrace();
42+
}
2843

2944
}
3045
}

simplesql/src/main/java/com/simplesql/simplesql/config/SimpleSQL.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ public boolean insert(Object obj) throws Throwable {
449449
throw new SQLException("This class does not have the table annotation");
450450
}
451451

452-
private static String checkAnnotations(Field c, boolean not_null) {
452+
private String checkAnnotations(Field c, boolean not_null) {
453453
String annotations = "";
454454
if (c.isAnnotationPresent(Key.class))
455455
annotations += " PRIMARY KEY";
@@ -465,7 +465,7 @@ private static String checkAnnotations(Field c, boolean not_null) {
465465
* Developed by Paulo Iury
466466
* Method DELETE TABLE
467467
*/
468-
public static String deleteTable(Object obj) throws SQLException {
468+
public String deleteTable(Object obj) throws SQLException {
469469
Table persistable =
470470
obj.getClass().getAnnotation(Table.class);
471471
if (persistable != null) {
@@ -537,8 +537,8 @@ public DeleteColumn fieldBoolean(int value) {
537537
return this;
538538
}
539539

540-
public DeleteColumn field(String field) {
541-
SQLString += field;
540+
public DeleteColumn column(String collumnName) {
541+
SQLString += collumnName;
542542
return this;
543543
}
544544

@@ -547,7 +547,7 @@ public DeleteColumn writeSQL(String sql) {
547547
return this;
548548
}
549549

550-
public boolean execute() {
550+
public boolean execute() throws SQLException{
551551
SQLiteDatabase escrever = helperBD.getWritableDatabase();
552552
try {
553553
escrever.execSQL("DELETE FROM " + table + " " + SQLString);

0 commit comments

Comments
 (0)