Skip to content

Commit

Permalink
added better way to delete data
Browse files Browse the repository at this point in the history
  • Loading branch information
p32929 committed May 12, 2019
1 parent 5bd3c89 commit 020fa0c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
*.iml
.gradle
/local.properties
/.idea/caches/build_file_checksums.ser
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/
.DS_Store
/build
/app/build
/app/release
/captures
*.externalNativeBuild
*.apk
*.apk
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ allprojects {
Add the dependency
```
dependencies {
implementation 'com.github.p32929:AndroidEasySQL-Library:1.3.11'
implementation 'com.github.p32929:AndroidEasySQL-Library:1.3.12'
}
```

Expand Down Expand Up @@ -220,6 +220,14 @@ To delete a row data, call ```deleteRow(rowId)``` like this:

```boolean deleted = easyDB.deleteRow(rowId);```

or

```boolean deleted = easyDB.deleteRow(columnNumber, valueToMatch)```

or

```boolean deleted = easyDB.deleteRow(columnName, valueToMatch)```

Thus, it will return a boolean value. So, you can know if your data is updated or not...

### Delete all data from the Table:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ public boolean deleteRow(int id) {
return db.delete(TABLE_NAME, "id = ?", new String[]{String.valueOf(id)}) == 1;
}

public boolean deleteRow(int columnNumber, int valueToMatch) {
SQLiteDatabase db = this.getWritableDatabase();
return db.delete(TABLE_NAME, columns.get(columnNumber - 1).columnName + " = ?", new String[]{String.valueOf(valueToMatch)}) == 1;
}

public boolean deleteRow(String columnName, int valueToMatch) {
SQLiteDatabase db = this.getWritableDatabase();
return db.delete(TABLE_NAME, columnName + " = ?", new String[]{String.valueOf(valueToMatch)}) == 1;
}

public void deleteAllDataFromTable() {
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("delete from " + TABLE_NAME);
Expand Down

0 comments on commit 020fa0c

Please sign in to comment.