Skip to content

Commit ec147a5

Browse files
committed
added two new methods
1 parent 9048f0e commit ec147a5

File tree

113 files changed

+347
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+347
-232
lines changed

.gradle/4.1/fileHashes/fileHashes.bin

2.59 KB
Binary file not shown.
0 Bytes
Binary file not shown.
748 Bytes
Binary file not shown.
22.6 KB
Binary file not shown.
3.39 KB
Binary file not shown.
0 Bytes
Binary file not shown.
97.1 KB
Binary file not shown.

.gradle/4.1/javaCompile/taskJars.bin

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

.idea/workspace.xml

Lines changed: 200 additions & 230 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,43 @@ public Cursor getAllData() {
9292
return res;
9393
}
9494

95+
public Cursor getOneRowData(int id) {
96+
if (!initedDb || writableDatabase == null) initDatabase();
97+
String allColNames[] = new String[columns.size() + 1];
98+
allColNames[0] = "ID";
99+
for (int i = 0; i < columns.size(); i++) {
100+
allColNames[i + 1] = columns.get(i).columnName;
101+
}
102+
Cursor cursor = writableDatabase.query(TABLE_NAME,
103+
allColNames,
104+
allColNames[0].toString() + "=?",
105+
new String[]{String.valueOf(id)},
106+
null, null, null, "1");
107+
108+
if (cursor.getCount() > 0) {
109+
return cursor;
110+
} else {
111+
return null;
112+
}
113+
}
114+
115+
public boolean matchColumns(String columnsToMatch[], String valuesToMatch[]) {
116+
String query = "";
117+
// columnsToMatch.get(0).columnName + " = ?" + " AND " + columnsToMatch.get(2).columnName + " = ?";
118+
for (int i = 0; i < columnsToMatch.length; i++) {
119+
query += columnsToMatch[i] + " = ? ";
120+
if (i != columnsToMatch.length - 1) {
121+
query += " AND ";
122+
}
123+
}
124+
Cursor cursor = writableDatabase.query(TABLE_NAME, columnsToMatch, query, valuesToMatch, null, null, null);
125+
if (cursor.getCount() > 0) {
126+
return true;
127+
} else {
128+
return false;
129+
}
130+
}
131+
95132
//
96133
public EasyDB updateData(int columnNumber, String data) {
97134
if (!initedDb || writableDatabase == null) initDatabase();
@@ -150,6 +187,16 @@ public EasyDB doneTableColumn() {
150187
return this;
151188
}
152189

190+
//
191+
public String[] getAllColumns() {
192+
String allColNames[] = new String[columns.size() + 1];
193+
allColNames[0] = "ID";
194+
for (int i = 0; i < columns.size(); i++) {
195+
allColNames[i + 1] = columns.get(i).columnName;
196+
}
197+
return allColNames;
198+
}
199+
153200
//
154201
public void initDatabase() {
155202
writableDatabase = getWritableDatabase();

app/src/main/java/p32929/databaseeasier/MainActivity.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
public class MainActivity extends AppCompatActivity {
1919

2020
EditText editTextC1, editTextC2;
21-
Button buttonSaver, buttonShow, buttonEdit, buttonDelete;
21+
Button buttonSaver, buttonShow, buttonEdit, buttonDelete, buttonMatch;
2222
TextView textViewResult;
2323

2424
EasyDB easyDB;
@@ -34,6 +34,7 @@ protected void onCreate(Bundle savedInstanceState) {
3434
buttonShow = findViewById(R.id.show_button);
3535
buttonEdit = findViewById(R.id.edit_button);
3636
buttonDelete = findViewById(R.id.delete_button);
37+
buttonMatch = findViewById(R.id.match_button);
3738
textViewResult = findViewById(R.id.res);
3839

3940
easyDB = EasyDB.init(this, "TEST", null, 1) // TEST is the name of the DATABASE
@@ -121,6 +122,19 @@ public void onClick(DialogInterface dialog, int which) {
121122
dialog.show();
122123
}
123124
});
125+
126+
buttonMatch.setOnClickListener(new View.OnClickListener() {
127+
@Override
128+
public void onClick(View view) {
129+
String c1 = editTextC1.getText().toString();
130+
String c2 = editTextC2.getText().toString();
131+
132+
String cols[] = easyDB.getAllColumns();
133+
134+
boolean matched = easyDB.matchColumns(new String[]{cols[1], cols[2]}, new String[]{c1, c2});
135+
Toast.makeText(MainActivity.this, "Matched = " + matched, Toast.LENGTH_SHORT).show();
136+
}
137+
});
124138
}
125139

126140

@@ -136,4 +150,21 @@ private void showData() {
136150
textViewResult.setText(tres);
137151
}
138152
}
153+
154+
public void getData1(View view) {
155+
String tres = "";
156+
Cursor res = easyDB.getOneRowData(1);
157+
if (res != null) {
158+
res.moveToFirst();
159+
160+
String row = res.getString(0);
161+
String c1 = res.getString(1);
162+
String c2 = res.getString(2);
163+
tres += "Row: " + row + " C1 = " + c1 + " C2 = " + c2 + "\n";
164+
165+
textViewResult.setText(tres);
166+
} else {
167+
Toast.makeText(this, "No Data", Toast.LENGTH_SHORT).show();
168+
}
169+
}
139170
}

app/src/main/res/layout/activity_main.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
android:layout_height="wrap_content"
2626
android:layout_marginTop="16dp"
2727
android:orientation="horizontal"
28-
android:weightSum="4">
28+
android:weightSum="3">
2929

3030
<Button
3131
android:id="@+id/saver_button"
@@ -48,13 +48,30 @@
4848
android:text="Edit"
4949
android:layout_weight="1" />
5050

51+
52+
</LinearLayout>
53+
54+
<LinearLayout
55+
android:layout_width="match_parent"
56+
android:orientation="horizontal"
57+
android:weightSum="2"
58+
android:layout_height="wrap_content">
59+
5160
<Button
5261
android:layout_width="wrap_content"
5362
android:id="@+id/delete_button"
5463
android:text="Delete"
5564
android:layout_height="wrap_content"
5665
android:layout_weight="1" />
5766

67+
<Button
68+
android:layout_width="wrap_content"
69+
android:id="@+id/match_button"
70+
android:text="Match"
71+
android:layout_height="wrap_content"
72+
android:layout_weight="1" />
73+
74+
5875

5976
</LinearLayout>
6077

@@ -68,6 +85,7 @@
6885
android:layout_width="match_parent"
6986
android:layout_height="wrap_content"
7087
android:layout_marginTop="16dp"
88+
android:onClick="getData1"
7189
android:textAlignment="center" />
7290

7391
</ScrollView>

build/android-profile/profile-2018-08-16-13-30-41-448.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-08-16-13-30-46-057.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-08-16-13-39-39-837.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-08-16-13-39-42-918.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-08-16-13-54-53-280.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-08-16-13-54-56-077.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-08-18-08-52-41-797.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-08-18-08-53-02-965.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-08-18-15-31-31-584.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-08-18-15-31-44-009.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-08-18-16-50-20-740.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-08-18-16-50-44-390.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-08-18-16-58-08-874.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-10-48-25-410.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-10-48-38-757.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-10-55-57-267.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-04-10-719.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-07-54-646.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-08-23-801.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-08-47-057.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-11-16-685.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-12-39-232.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-12-53-056.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-14-35-475.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-22-34-205.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-23-24-554.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-23-45-390.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-24-06-837.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-25-11-522.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-26-05-414.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-27-14-350.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-29-08-733.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-30-02-653.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-31-49-817.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-34-37-137.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-37-02-871.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-37-44-980.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-38-42-290.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-39-35-851.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-40-35-470.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-41-37-184.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-41-59-622.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-42-51-674.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-11-46-17-472.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-12-02-22-467.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-12-02-34-561.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-12-04-25-454.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-12-04-44-281.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

build/android-profile/profile-2018-10-16-12-06-01-920.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

0 commit comments

Comments
 (0)