Skip to content

Commit 020fa0c

Browse files
committed
added better way to delete data
1 parent 5bd3c89 commit 020fa0c

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

.gitignore

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
*.iml
22
.gradle
33
/local.properties
4-
/.idea/caches/build_file_checksums.ser
5-
/.idea/libraries
6-
/.idea/modules.xml
7-
/.idea/workspace.xml
4+
/.idea/
85
.DS_Store
96
/build
7+
/app/build
8+
/app/release
109
/captures
1110
*.externalNativeBuild
12-
*.apk
11+
*.apk

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ allprojects {
1414
Add the dependency
1515
```
1616
dependencies {
17-
implementation 'com.github.p32929:AndroidEasySQL-Library:1.3.11'
17+
implementation 'com.github.p32929:AndroidEasySQL-Library:1.3.12'
1818
}
1919
```
2020

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

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

223+
or
224+
225+
```boolean deleted = easyDB.deleteRow(columnNumber, valueToMatch)```
226+
227+
or
228+
229+
```boolean deleted = easyDB.deleteRow(columnName, valueToMatch)```
230+
223231
Thus, it will return a boolean value. So, you can know if your data is updated or not...
224232

225233
### Delete all data from the Table:

androideasysql-library/src/main/java/p32929/androideasysql_library/EasyDB.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,16 @@ public boolean deleteRow(int id) {
257257
return db.delete(TABLE_NAME, "id = ?", new String[]{String.valueOf(id)}) == 1;
258258
}
259259

260+
public boolean deleteRow(int columnNumber, int valueToMatch) {
261+
SQLiteDatabase db = this.getWritableDatabase();
262+
return db.delete(TABLE_NAME, columns.get(columnNumber - 1).columnName + " = ?", new String[]{String.valueOf(valueToMatch)}) == 1;
263+
}
264+
265+
public boolean deleteRow(String columnName, int valueToMatch) {
266+
SQLiteDatabase db = this.getWritableDatabase();
267+
return db.delete(TABLE_NAME, columnName + " = ?", new String[]{String.valueOf(valueToMatch)}) == 1;
268+
}
269+
260270
public void deleteAllDataFromTable() {
261271
SQLiteDatabase db = this.getWritableDatabase();
262272
db.execSQL("delete from " + TABLE_NAME);

0 commit comments

Comments
 (0)