├── .gitignore
├── .idea
├── gradle.xml
├── misc.xml
├── runConfigurations.xml
└── vcs.xml
├── LICENSE
├── README.md
├── androideasysql-library
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── p32929
│ │ └── androideasysql_library
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── p32929
│ │ │ └── androideasysql_library
│ │ │ ├── Column.java
│ │ │ └── EasyDB.java
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── p32929
│ └── androideasysql_library
│ └── ExampleUnitTest.java
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── p32929
│ │ └── databaseeasier
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── p32929
│ │ │ └── databaseeasier
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── p32929
│ └── databaseeasier
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/
5 | .DS_Store
6 | /build
7 | /app/build
8 | /app/release
9 | /captures
10 | *.externalNativeBuild
11 | *.apk
12 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Fayaz Bin Salam
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # UPDATE!!!
2 | A newer, easier and better version of this library (V2) can be found here:
3 |
4 | https://github.com/p32929/EasiestSqlLibrary
5 |
6 | But if you want, you can still use this library. If you like Flutter, the flutter version of this library can be found here -> [Github](https://github.com/p32929/EasiestSqlFlutter) or [pub.dev](https://pub.dev/packages/easiestdb) . Thanks...
7 |
8 | # AndroidEasySQL-Library
9 | An Easier & Lazier approach to SQL database for Android
10 |
11 | []() []() []() []() []() []() []() []() []() []() []() []() []() []() []() []() []() []() []() []() []() []() []() []()
12 |
13 | ## Share
14 | Sharing with your friends is just one click away from here
15 |
16 | [](https://www.facebook.com/sharer/sharer.php?u=https://github.com/p32929/AndroidEasySQL-Library)
17 | [](https://twitter.com/intent/tweet?source=https://github.com/p32929/AndroidEasySQL-Library)
18 | [](https://www.tumblr.com/share?v=3&u=https://github.com/p32929/AndroidEasySQL-Library)
19 | [](https://getpocket.com/save?url=https://github.com/p32929/AndroidEasySQL-Library)
20 | [](https://pinterest.com/pin/create/button/?url=https://github.com/p32929/AndroidEasySQL-Library)
21 | [](https://www.reddit.com/submit?url=https://github.com/p32929/AndroidEasySQL-Library)
22 | [](https://www.linkedin.com/shareArticle?mini=true&url=https://github.com/p32929/AndroidEasySQL-Library)
23 | [](https://api.whatsapp.com/send?text=https://github.com/p32929/AndroidEasySQL-Library)
24 |
25 | ## Support
26 | If you like my works and want to support me/my works, feel free to support or donate. My payment details can be found here: https://p32929.github.io/SendMoney2Me/
27 |
28 | ## Installation
29 | Add it in your root build.gradle at the end of repositories:
30 | ```
31 | allprojects {
32 | repositories {
33 | maven { url 'https://jitpack.io' }
34 | }
35 | }
36 | ```
37 |
38 | Add the dependency
39 | ```
40 | dependencies {
41 | implementation 'com.github.p32929:AndroidEasySQL-Library:1.4.1'
42 | }
43 | ```
44 |
45 | ## Basic Usage
46 | Steps to follow:
47 | * Initialize
48 | * Set Table Name (Not mandatory)
49 | * Add columns
50 | * Call done method
51 |
52 | After that you can do:
53 | * Add data
54 | * Read data
55 | * Edit data
56 | * Delete data
57 | * & so much more
58 |
59 | ## Code example
60 | ### Initialization, Set Table Name, Add columns, altogether:
61 |
62 | ```
63 | EasyDB easyDB = EasyDB.init(this, "TEST") // TEST is the name of the DATABASE
64 | .setTableName("DEMO TABLE") // You can ignore this line if you want
65 | .addColumn("C1", "text") // Contrains like "text", "unique", "not null" are not case sensitive
66 | .addColumn("C2", "text", "unique")
67 | .addColumn("C3", "text", "unique", "not null")
68 | .doneTableColumn();
69 | ```
70 |
71 | or
72 |
73 | ```
74 | EasyDB easyDB = EasyDB.init(this, "TEST") // "TEST" is the name of the DATABASE
75 | .setTableName("DEMO TABLE") // You can ignore this line if you want
76 | .addColumn(new Column("C1", "text", "unique")) // Contrains like "text", "unique", "not null" are not case sensitive
77 | .addColumn(new Column("C2", "text", "not null"))
78 | .addColumn(new Column("C3", "text"))
79 | .doneTableColumn();
80 | ```
81 |
82 | ** Saving the ```easyDB``` object into a variable will make easier to work with the database later. **
83 |
84 | ** You don't have to add any primary key. The library does it by default (as ```ID``` column) **
85 |
86 | ### Adding data:
87 | You can call the ```addData()``` in two ways:
88 |
89 | > addData(columnNumber, data) // ```columnNumber``` is an integer
90 |
91 | > addData(columnName, data) // ```columnName``` is a String
92 |
93 | ```data``` parameter in ```addData()``` can be either integer or string. After adding all the data, call ```doneDataAdding()``` method.
94 |
95 | Example:
96 | ```
97 | boolean done = easyDB.addData(1, "Data1")
98 | .addData(2, "Data2")
99 | .addData(3, "Data3")
100 | .doneDataAdding();
101 | ```
102 |
103 | or
104 |
105 | ```
106 | boolean done = easyDB.addData("C1", "Data1")
107 | .addData("C2", "Data2")
108 | .addData("C3", "Data3")
109 | .doneDataAdding();
110 | ```
111 |
112 | Thus, it will return a boolean value.
113 | ```True``` means data added successfully,
114 | ```False``` means data isn't added successfully.
115 |
116 | ### Get/Read All Data:
117 | To get all data as a ```Cursor``` object, call ```getAllData()``` or ```getAllDataOrderedBy()``` like this:
118 |
119 | ```Cursor res = easyDB.getAllData();```
120 |
121 | or
122 |
123 | ```Cursor res = easyDB.getAllDataOrderedBy(columnNumber, ascendingOrDescending);```
124 |
125 | ```ascendingOrDescending``` parameter in ```getAllDataOrderedBy()``` is a boolean value. To get all data in ascending order pass ```true```, or to get all data in descending order pass ```false``` as the parameter.
126 |
127 | Later use a while loop like this:
128 |
129 | ```
130 | while (res.moveToNext()) {
131 | // Your code here
132 | }
133 | ```
134 |
135 | To get an integer from ```res``` call ```getInt(columnIndex)``` and to get a String call ```getString(columnIndex)``` like this:
136 | ```
137 | int anIntegerVariable = res.getInt(columnIndex);
138 | String aStringVariable = res.getString(columnIndex);
139 | ```
140 |
141 | here ```columnIndex``` is an integer, starts from 0.
142 |
143 | Example:
144 |
145 | ```
146 | Cursor res = easyDB.getAllData();
147 | while (res.moveToNext()) {
148 | int anIntegerVariable = res.getInt(columnIndex);
149 | String aStringVariable = res.getString(columnIndex);
150 | }
151 | ```
152 |
153 | or
154 |
155 | ```
156 | Cursor res = easyDB.getAllDataOrderedBy(columnNumber, false);
157 | while (res.moveToNext()) {
158 | int anIntegerVariable = res.getInt(columnIndex);
159 | String aStringVariable = res.getString(columnIndex);
160 | }
161 | ```
162 |
163 |
164 | ### Get/Read one row data:
165 | To get data from a row, call ```getOneRowData(rowID)```. It will return the data as a Cursor object. You can then retrieve each column data from the cursor.
166 | Example:
167 | ```
168 | Cursor res = easyDB.getOneRowData(1);
169 | if (res != null) {
170 | res.moveToFirst(); // Because here's only one row data
171 | String ID = res.getString(0); // Column 0 is the ID column
172 | String c1 = res.getString(1);
173 | String c2 = res.getString(2);
174 | }
175 | ```
176 |
177 | ### Get/Read/Search one/multiple row data by matching a column data:
178 | To get data from one/multiple rows by matching data with a column, call ```searchInColumn(columnNumber, valueToSearch, limit)``` or ```searchInColumn(columnName, valueToSearch, limit)```
179 | example:
180 | ```
181 | Cursor res = easyDB.searchInColumn(1, "data", 1); // Here we passed limit = 1. Thus it will return only one row data with the matched column value
182 | if (res != null) {
183 | res.moveToFirst(); // Because here's only one row data
184 | String ID = res.getString(0); // Column 0 is the ID column
185 | String c1 = res.getString(1);
186 | String c2 = res.getString(2);
187 | }
188 | ```
189 |
190 | or
191 |
192 | ```
193 | Cursor res = easyDB.searchInColumn("ID", "data", -1); // Here we passed limit = -1. Thus it will return all the rows with the matched column values
194 | if (res != null) {
195 | while (res.moveToNext()) {
196 | String ID = res.getString(0); // Column 0 is the ID column
197 | String c1 = res.getString(1);
198 | String c2 = res.getString(2);
199 | }
200 | }
201 | ```
202 |
203 | > Please DO NOT pass ```limit = 0``` as the parameter
204 |
205 | ### Match data from multiple columns:
206 | To check if some values exist or not in the database, first call ```getAllColumns()``` to get all the column names like this:
207 |
208 | ```String columns[] = easyDB.getAllColumns();```
209 |
210 | Now, You may create an array of ```String``` defining which columns you want to match with some values, like this:
211 |
212 | ```
213 | String columnsToMatch[] = new String[]{columns[1], columns[2]};
214 | ```
215 | And an array of values(String) you want to match, like this:
216 |
217 | ```
218 | String valuesToMatch[] = new String[]{valueToSearchInColumn1, valueToSearchInColumn2};
219 | ```
220 |
221 | Now call ```matchColumns()``` like this:
222 |
223 | ```boolean matched = easyDB.matchColumns(columnsToMatch, valuesToMatch);```
224 |
225 | Thus, it will return a boolean value. So, you can know if your given values are matched or not.
226 |
227 | ** Creating these two array variables(```columnsToMatch``` & ```valuesToMatch```) will make it easier to pass them into ```matchColumns()``` method. **
228 |
229 | ### Update / Edit data:
230 | To update / Edit, call ```updateData(columnNumber, data)``` method.
231 | Example:
232 | ```
233 | boolean updated = easyDB.updateData(1, "UpdatedData1")
234 | .updateData(2, "UpdatedData2")
235 | .updateData(3, "UpdatedData3")
236 | .rowID(id);
237 | ```
238 |
239 | UpdatedData can be either integer or String.
240 | Thus, it will return a boolean value. So, you can know if your data is updated or not...
241 |
242 | ### Delete data:
243 | To delete a row data, call ```deleteRow(rowId)``` like this:
244 |
245 | ```boolean deleted = easyDB.deleteRow(rowId);```
246 |
247 | or
248 |
249 | ```boolean deleted = easyDB.deleteRow(columnNumber, valueToMatch)```
250 |
251 | or
252 |
253 | ```boolean deleted = easyDB.deleteRow(columnName, valueToMatch)```
254 |
255 | Thus, it will return a boolean value. So, you can know if your data is updated or not...
256 |
257 | ### Delete all data from the Table:
258 | To delete the table and its all data, call ```deleteAllDataFromTable``` like this:
259 |
260 | ```easyDB.deleteAllDataFromTable();```
261 |
262 | Hope you'll enjoy using the library :)
263 |
264 | > Thanks
265 |
266 | ## License:
267 | ```
268 | MIT License
269 |
270 | Copyright (c) 2018 Fayaz Bin Salam
271 |
272 | Permission is hereby granted, free of charge, to any person obtaining a copy
273 | of this software and associated documentation files (the "Software"), to deal
274 | in the Software without restriction, including without limitation the rights
275 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
276 | copies of the Software, and to permit persons to whom the Software is
277 | furnished to do so, subject to the following conditions:
278 |
279 | The above copyright notice and this permission notice shall be included in all
280 | copies or substantial portions of the Software.
281 |
282 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
283 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
284 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
285 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
286 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
287 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
288 | SOFTWARE.
289 | ```
290 |
--------------------------------------------------------------------------------
/androideasysql-library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/androideasysql-library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 27
5 |
6 | defaultConfig {
7 | minSdkVersion 15
8 | targetSdkVersion 27
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 |
14 | buildTypes {
15 | release {
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 |
20 | }
21 |
22 | dependencies {
23 | implementation fileTree(dir: 'libs', include: ['*.jar'])
24 | }
25 |
--------------------------------------------------------------------------------
/androideasysql-library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/androideasysql-library/src/androidTest/java/p32929/androideasysql_library/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package p32929.androideasysql_library;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("p32929.androideasysql_library.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/androideasysql-library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/androideasysql-library/src/main/java/p32929/androideasysql_library/Column.java:
--------------------------------------------------------------------------------
1 | package p32929.androideasysql_library;
2 |
3 | /**
4 | * Created by p32929 on 7/8/18.
5 | */
6 |
7 | /*
8 | MIT License
9 |
10 | Copyright (c) 2018 Fayaz Bin Salam
11 |
12 | Permission is hereby granted, free of charge, to any person obtaining a copy
13 | of this software and associated documentation files (the "Software"), to deal
14 | in the Software without restriction, including without limitation the rights
15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 | copies of the Software, and to permit persons to whom the Software is
17 | furnished to do so, subject to the following conditions:
18 |
19 | The above copyright notice and this permission notice shall be included in all
20 | copies or substantial portions of the Software.
21 |
22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 | SOFTWARE.
29 | */
30 |
31 | public class Column {
32 |
33 | //
34 | String columnName, columnDataType;
35 |
36 | public Column (String columnName, String... columnDataTypes) {
37 | this.columnName = columnName.replaceAll(" ", "_");
38 | String finalDatatype = "";
39 | for (int i = 0; i < columnDataTypes.length; i++) {
40 | if (!columnDataTypes[i].startsWith(" ")) {
41 | columnDataTypes[i] = " " + columnDataTypes[i];
42 | }
43 | if (!columnDataTypes[i].endsWith(" ")) {
44 | columnDataTypes[i] = columnDataTypes[i] + " ";
45 | }
46 | finalDatatype += columnDataTypes[i].toUpperCase();
47 | }
48 | this.columnDataType = finalDatatype;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/androideasysql-library/src/main/java/p32929/androideasysql_library/EasyDB.java:
--------------------------------------------------------------------------------
1 | package p32929.androideasysql_library;
2 |
3 | import android.content.ContentValues;
4 | import android.content.Context;
5 | import android.database.Cursor;
6 | import android.database.DatabaseErrorHandler;
7 | import android.database.sqlite.SQLiteDatabase;
8 | import android.database.sqlite.SQLiteOpenHelper;
9 |
10 | import java.util.ArrayList;
11 |
12 | /**
13 | * Created by p32929 on 7/8/18.
14 | */
15 |
16 | /*
17 | MIT License
18 |
19 | Copyright (c) 2018 Fayaz Bin Salam
20 |
21 | Permission is hereby granted, free of charge, to any person obtaining a copy
22 | of this software and associated documentation files (the "Software"), to deal
23 | in the Software without restriction, including without limitation the rights
24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25 | copies of the Software, and to permit persons to whom the Software is
26 | furnished to do so, subject to the following conditions:
27 |
28 | The above copyright notice and this permission notice shall be included in all
29 | copies or substantial portions of the Software.
30 |
31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37 | SOFTWARE.
38 | */
39 |
40 | public class EasyDB extends SQLiteOpenHelper {
41 |
42 |
43 | // Variables
44 | private String DATABASE_NAME, TABLE_NAME = "DEMO_TABLE", SQL = "";
45 | private ArrayList columns = new ArrayList<>();
46 | private SQLiteDatabase writableDatabase;
47 | private ContentValues contentValues = new ContentValues();
48 | private boolean initedDb = false;
49 |
50 | //
51 | public EasyDB addData(int columnNumber, String data) {
52 | if (!initedDb || writableDatabase == null) initDatabase();
53 | contentValues.put(columns.get(columnNumber - 1).columnName, data);
54 | return this;
55 | }
56 |
57 | public EasyDB addData(String columnName, String data) {
58 | columnName = columnName.replaceAll(" ", "_");
59 | if (!initedDb || writableDatabase == null) initDatabase();
60 | contentValues.put(columnName, data);
61 | return this;
62 | }
63 |
64 | public EasyDB addData(int columnNumber, int data) {
65 | if (!initedDb || writableDatabase == null) initDatabase();
66 | contentValues.put(columns.get(columnNumber - 1).columnName, data);
67 | return this;
68 | }
69 |
70 | public EasyDB addData(String columnName, int data) {
71 | columnName = columnName.replaceAll(" ", "_");
72 | if (!initedDb || writableDatabase == null) initDatabase();
73 | contentValues.put(columnName, data);
74 | return this;
75 | }
76 |
77 |
78 | public boolean doneDataAdding() {
79 | long result = writableDatabase.insert(TABLE_NAME, null, contentValues);
80 | contentValues = new ContentValues();
81 |
82 | if (result == -1)
83 | return false;
84 | else
85 | return true;
86 | }
87 |
88 | //
89 | public Cursor getAllData() {
90 | if (!initedDb || writableDatabase == null) initDatabase();
91 | Cursor res = writableDatabase.rawQuery("select * from " + TABLE_NAME, null);
92 | return res;
93 | }
94 |
95 | public Cursor getAllDataOrderedBy(int columnNumber, boolean ascending) {
96 | String postfix = ascending ? "" : " DESC ";
97 | String colNam = columnNumber == 0 ? " ID " : columns.get(columnNumber - 1).columnName;
98 | if (!initedDb || writableDatabase == null) initDatabase();
99 | Cursor res = writableDatabase.rawQuery("select * from " + TABLE_NAME + " ORDER BY " + colNam + postfix, null);
100 | return res;
101 | }
102 |
103 | //
104 | public Cursor getOneRowData(int rowID) {
105 | if (!initedDb || writableDatabase == null) initDatabase();
106 | String allColNames[] = new String[columns.size() + 1];
107 | allColNames[0] = "ID";
108 | for (int i = 0; i < columns.size(); i++) {
109 | allColNames[i + 1] = columns.get(i).columnName;
110 | }
111 | Cursor cursor = writableDatabase.query(TABLE_NAME,
112 | allColNames, allColNames[0].toString() + "=?",
113 | new String[]{String.valueOf(rowID)},
114 | null, null, null, "1");
115 |
116 | if (cursor.getCount() > 0) {
117 | return cursor;
118 | } else {
119 | return null;
120 | }
121 | }
122 |
123 | @Deprecated
124 | public Cursor getOneRowData(int columnNumber, String value) {
125 | if (!initedDb || writableDatabase == null) initDatabase();
126 | String allColNames[] = new String[columns.size() + 1];
127 | allColNames[0] = "ID";
128 | for (int i = 0; i < columns.size(); i++) {
129 | allColNames[i + 1] = columns.get(i).columnName;
130 | }
131 | Cursor cursor = writableDatabase.query(TABLE_NAME,
132 | allColNames, allColNames[columnNumber].toString() + "=?",
133 | new String[]{value},
134 | null, null, null, "1");
135 |
136 | if (cursor.getCount() > 0) {
137 | return cursor;
138 | } else {
139 | return null;
140 | }
141 | }
142 |
143 | @Deprecated
144 | public Cursor getOneRowData(String columnName, String value) {
145 | if (!initedDb || writableDatabase == null) initDatabase();
146 | String allColNames[] = new String[columns.size() + 1];
147 | allColNames[0] = "ID";
148 | for (int i = 0; i < columns.size(); i++) {
149 | allColNames[i + 1] = columns.get(i).columnName;
150 | }
151 | Cursor cursor = writableDatabase.query(TABLE_NAME,
152 | allColNames, " " + columnName + " " + "=?",
153 | new String[]{value},
154 | null, null, null, "1");
155 |
156 | if (cursor.getCount() > 0) {
157 | return cursor;
158 | } else {
159 | return null;
160 | }
161 | }
162 |
163 | public Cursor searchInColumn(int columnNumber, String valueToSearch, int limit) {
164 | if (!initedDb || writableDatabase == null) initDatabase();
165 | String allColNames[] = new String[columns.size() + 1];
166 | allColNames[0] = "ID";
167 | for (int i = 0; i < columns.size(); i++) {
168 | allColNames[i + 1] = columns.get(i).columnName;
169 | }
170 | Cursor cursor = writableDatabase.query(TABLE_NAME,
171 | allColNames, allColNames[columnNumber].toString() + "=?",
172 | new String[]{valueToSearch},
173 | null, null, null, limit == -1 ? null : String.valueOf(limit));
174 |
175 | if (cursor.getCount() > 0) {
176 | return cursor;
177 | } else {
178 | return null;
179 | }
180 | }
181 |
182 | public Cursor searchInColumn(String columnName, String valueToSearch, int limit) {
183 | if (!initedDb || writableDatabase == null) initDatabase();
184 | String allColNames[] = new String[columns.size() + 1];
185 | allColNames[0] = "ID";
186 | for (int i = 0; i < columns.size(); i++) {
187 | allColNames[i + 1] = columns.get(i).columnName;
188 | }
189 | Cursor cursor = writableDatabase.query(TABLE_NAME,
190 | allColNames, " " + columnName + " " + "=?",
191 | new String[]{valueToSearch},
192 | null, null, null, limit == -1 ? null : String.valueOf(limit));
193 |
194 | if (cursor.getCount() > 0) {
195 | return cursor;
196 | } else {
197 | return null;
198 | }
199 | }
200 |
201 | //
202 | public boolean matchColumns(String columnsToMatch[], String valuesToMatch[]) {
203 | String query = "";
204 | for (int i = 0; i < columnsToMatch.length; i++) {
205 | query += columnsToMatch[i] + " = ? ";
206 | if (i != columnsToMatch.length - 1) {
207 | query += " AND ";
208 | }
209 | }
210 | Cursor cursor = writableDatabase.query(TABLE_NAME, columnsToMatch, query, valuesToMatch, null, null, null);
211 | if (cursor.getCount() > 0) {
212 | return true;
213 | } else {
214 | return false;
215 | }
216 | }
217 |
218 | //
219 | public EasyDB updateData(int columnNumber, String data) {
220 | if (!initedDb || writableDatabase == null) initDatabase();
221 | contentValues.put(columns.get(columnNumber - 1).columnName, data);
222 | return this;
223 | }
224 |
225 | public EasyDB updateData(int columnNumber, int data) {
226 | if (!initedDb || writableDatabase == null) initDatabase();
227 | contentValues.put(columns.get(columnNumber - 1).columnName, data);
228 | return this;
229 | }
230 |
231 | public EasyDB updateData(String columnName, String data) {
232 | columnName = columnName.replaceAll(" ", "_");
233 | if (!initedDb || writableDatabase == null) initDatabase();
234 | contentValues.put(columnName, data);
235 | return this;
236 | }
237 |
238 | public EasyDB updateData(String columnName, int data) {
239 | columnName = columnName.replaceAll(" ", "_");
240 | if (!initedDb || writableDatabase == null) initDatabase();
241 | contentValues.put(columnName, data);
242 | return this;
243 | }
244 |
245 |
246 | public boolean rowID(int id) {
247 | try {
248 | return writableDatabase.update(TABLE_NAME, contentValues, "id = ?", new String[]{String.valueOf(id)}) > 0;
249 | } catch (Exception e) {
250 | return false;
251 | }
252 | }
253 |
254 | //
255 | public boolean deleteRow(int id) {
256 | SQLiteDatabase db = this.getWritableDatabase();
257 | return db.delete(TABLE_NAME, "id = ?", new String[]{String.valueOf(id)}) == 1;
258 | }
259 |
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(int columnNumber, String valueToMatch) {
266 | SQLiteDatabase db = this.getWritableDatabase();
267 | return db.delete(TABLE_NAME, columns.get(columnNumber - 1).columnName + " = ?", new String[]{valueToMatch}) == 1;
268 | }
269 |
270 | public boolean deleteRow(String columnName, int valueToMatch) {
271 | SQLiteDatabase db = this.getWritableDatabase();
272 | return db.delete(TABLE_NAME, columnName + " = ?", new String[]{String.valueOf(valueToMatch)}) == 1;
273 | }
274 |
275 | public boolean deleteRow(String columnName, String valueToMatch) {
276 | SQLiteDatabase db = this.getWritableDatabase();
277 | return db.delete(TABLE_NAME, columnName + " = ?", new String[]{valueToMatch}) == 1;
278 | }
279 |
280 | public void deleteAllDataFromTable() {
281 | SQLiteDatabase db = this.getWritableDatabase();
282 | db.execSQL("delete from " + TABLE_NAME);
283 | }
284 |
285 | //
286 | public EasyDB setTableName(String tableName) {
287 | this.TABLE_NAME = tableName.replaceAll(" ", "_");
288 | return this;
289 | }
290 |
291 | public EasyDB addColumn(Column column) {
292 | columns.add(column);
293 | return this;
294 | }
295 |
296 | public EasyDB addColumn(String columnName, String... columnDataTypes) {
297 | Column column = new Column(columnName, columnDataTypes);
298 | columns.add(column);
299 | return this;
300 | }
301 |
302 | public EasyDB doneTableColumn() {
303 | SQL = " CREATE TABLE " + TABLE_NAME + " ( ID INTEGER PRIMARY KEY AUTOINCREMENT, ";
304 | for (int i = 0; i < columns.size(); i++) {
305 | SQL += " " + columns.get(i).columnName + " " + columns.get(i).columnDataType + " ";
306 | if (i == columns.size() - 1) {
307 | SQL += " ) ";
308 | } else {
309 | SQL += " , ";
310 | }
311 | }
312 |
313 | if (!initedDb || writableDatabase == null) initDatabase();
314 | return this;
315 | }
316 |
317 | //
318 | public String[] getAllColumns() {
319 | String allColNames[] = new String[columns.size() + 1];
320 | allColNames[0] = "ID";
321 | for (int i = 0; i < columns.size(); i++) {
322 | allColNames[i + 1] = columns.get(i).columnName;
323 | }
324 | return allColNames;
325 | }
326 |
327 | //
328 | private void initDatabase() {
329 | writableDatabase = getWritableDatabase();
330 | initedDb = true;
331 | }
332 |
333 | //
334 | public static EasyDB init(Context context, String dbName) {
335 | if (!dbName.endsWith(".db"))
336 | dbName += ".db";
337 | dbName = dbName.replaceAll(" ", "_");
338 | return new EasyDB(context, dbName, null, 1);
339 | }
340 |
341 | public static EasyDB init(Context context, String dbName, int version) {
342 | if (!dbName.endsWith(".db"))
343 | dbName += ".db";
344 | dbName = dbName.replaceAll(" ", "_");
345 | return new EasyDB(context, dbName, null, version);
346 | }
347 |
348 | public static EasyDB init(Context context, String dbName, SQLiteDatabase.CursorFactory factory, int version) {
349 | if (!dbName.endsWith(".db"))
350 | dbName += ".db";
351 | dbName = dbName.replaceAll(" ", "_");
352 | return new EasyDB(context, dbName, factory, version);
353 | }
354 |
355 | public static EasyDB init(Context context, String dbName, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
356 | if (!dbName.endsWith(".db"))
357 | dbName += ".db";
358 | dbName = dbName.replaceAll(" ", "_");
359 | return new EasyDB(context, dbName, factory, version, errorHandler);
360 | }
361 |
362 | //
363 | @Override
364 | public void onCreate(SQLiteDatabase db) {
365 | this.writableDatabase = db;
366 | db.execSQL(SQL);
367 | }
368 |
369 | @Override
370 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
371 | db.execSQL(" DROP TABLE IF EXISTS " + TABLE_NAME);
372 | onCreate(db);
373 | }
374 |
375 | // Saving, just in case :)
376 | // Codes below this might once or never be used :D
377 | private Context context;
378 | private SQLiteDatabase.CursorFactory factory;
379 | private int version;
380 | private DatabaseErrorHandler errorHandler;
381 |
382 | private EasyDB(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
383 | super(context, name, factory, version);
384 |
385 | //
386 | this.context = context;
387 | this.DATABASE_NAME = name;
388 | this.factory = factory;
389 | this.version = version;
390 | }
391 |
392 | private EasyDB(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
393 | super(context, name, factory, version, errorHandler);
394 |
395 | //
396 | this.context = context;
397 | this.DATABASE_NAME = name;
398 | this.factory = factory;
399 | this.version = version;
400 | this.errorHandler = errorHandler;
401 | }
402 | }
403 |
--------------------------------------------------------------------------------
/androideasysql-library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AndroidEasySQL-Library
3 |
4 |
--------------------------------------------------------------------------------
/androideasysql-library/src/test/java/p32929/androideasysql_library/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package p32929.androideasysql_library;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 27
5 | defaultConfig {
6 | applicationId "p32929.databaseeasier"
7 | minSdkVersion 15
8 | targetSdkVersion 27
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'com.android.support:appcompat-v7:27.1.1'
24 | implementation 'com.android.support.constraint:constraint-layout:1.1.2'
25 | testImplementation 'junit:junit:4.12'
26 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
28 | implementation project(path: ':androideasysql-library')
29 | }
30 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/p32929/databaseeasier/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package p32929.databaseeasier;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("p32929.databaseeasier", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/p32929/databaseeasier/MainActivity.java:
--------------------------------------------------------------------------------
1 | package p32929.databaseeasier;
2 |
3 | import android.content.DialogInterface;
4 | import android.database.Cursor;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AlertDialog;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.EditText;
11 | import android.widget.TextView;
12 | import android.widget.Toast;
13 |
14 | import p32929.androideasysql_library.Column;
15 | import p32929.androideasysql_library.EasyDB;
16 |
17 | public class MainActivity extends AppCompatActivity {
18 |
19 | EditText editTextC1, editTextC2;
20 | Button buttonSaver, buttonShow, buttonEdit, buttonDelete, buttonMatch;
21 | TextView textViewResult;
22 |
23 | EasyDB easyDB;
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_main);
29 |
30 | editTextC1 = findViewById(R.id.c1);
31 | editTextC2 = findViewById(R.id.c2);
32 | buttonSaver = findViewById(R.id.saver_button);
33 | buttonShow = findViewById(R.id.show_button);
34 | buttonEdit = findViewById(R.id.edit_button);
35 | buttonDelete = findViewById(R.id.delete_button);
36 | buttonMatch = findViewById(R.id.match_button);
37 | textViewResult = findViewById(R.id.res);
38 |
39 | easyDB = EasyDB.init(this, "TEST") // TEST is the name of the DATABASE
40 | .setTableName("DEMO TABLE") // You can ignore this line if you want
41 | .addColumn("C1", "text")
42 | .addColumn("C2", "text", "unique")
43 | .doneTableColumn();
44 |
45 | buttonShow.setOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View view) {
48 | showData();
49 | }
50 | });
51 |
52 | buttonSaver.setOnClickListener(new View.OnClickListener() {
53 | @Override
54 | public void onClick(View view) {
55 | String c1 = editTextC1.getText().toString();
56 | String c2 = editTextC2.getText().toString();
57 |
58 | if (c1 != null && c2 != null) {
59 | if (!c1.isEmpty() && !c2.isEmpty()) {
60 | boolean done = easyDB.addData(1, c1)
61 | .addData(2, c2)
62 | .doneDataAdding();
63 |
64 | Toast.makeText(MainActivity.this, "Done: " + done, Toast.LENGTH_SHORT).show();
65 | showData();
66 | }
67 | }
68 | }
69 | });
70 |
71 | buttonEdit.setOnClickListener(new View.OnClickListener() {
72 | @Override
73 | public void onClick(View view) {
74 | final EditText taskEditText = new EditText(MainActivity.this);
75 | AlertDialog dialog = new AlertDialog.Builder(MainActivity.this)
76 | .setTitle("Edit Data")
77 | .setMessage("Enter row number")
78 | .setView(taskEditText)
79 | .setPositiveButton("Update", new DialogInterface.OnClickListener() {
80 | @Override
81 | public void onClick(DialogInterface dialog, int which) {
82 | String c1 = editTextC1.getText().toString();
83 | String c2 = editTextC2.getText().toString();
84 |
85 | if (c1 != null && c2 != null) {
86 | if (!c1.isEmpty() && !c2.isEmpty()) {
87 | boolean done = easyDB.updateData(1, c1)
88 | .updateData(2, c2)
89 | .rowID(Integer.valueOf(taskEditText.getText().toString()));
90 |
91 | Toast.makeText(MainActivity.this, "Updated: " + done, Toast.LENGTH_SHORT).show();
92 | showData();
93 | }
94 | }
95 | }
96 | })
97 | .setNegativeButton("Cancel", null)
98 | .create();
99 | dialog.show();
100 | }
101 | });
102 |
103 | buttonDelete.setOnClickListener(new View.OnClickListener() {
104 | @Override
105 | public void onClick(View view) {
106 | final EditText taskEditText = new EditText(MainActivity.this);
107 | AlertDialog dialog = new AlertDialog.Builder(MainActivity.this)
108 | .setTitle("Delete Data")
109 | .setMessage("Enter row number")
110 | .setView(taskEditText)
111 | .setPositiveButton("Delete", new DialogInterface.OnClickListener() {
112 | @Override
113 | public void onClick(DialogInterface dialog, int which) {
114 | boolean deleted = easyDB.deleteRow(Integer.valueOf(taskEditText.getText().toString()));
115 | Toast.makeText(MainActivity.this, "Deleted: " + deleted, Toast.LENGTH_SHORT).show();
116 | showData();
117 | }
118 | })
119 | .setNegativeButton("Cancel", null)
120 | .create();
121 | dialog.show();
122 | }
123 | });
124 |
125 | buttonMatch.setOnClickListener(new View.OnClickListener() {
126 | @Override
127 | public void onClick(View view) {
128 | String c1 = editTextC1.getText().toString();
129 | String c2 = editTextC2.getText().toString();
130 | String cols[] = easyDB.getAllColumns();
131 |
132 | String columnsToMatch[] = new String[]{cols[1], cols[2]};
133 | String valuesToMatch[] = new String[]{c1, c2};
134 |
135 | boolean matched = easyDB.matchColumns(columnsToMatch, valuesToMatch);
136 | Toast.makeText(MainActivity.this, "Matched = " + matched, Toast.LENGTH_SHORT).show();
137 | }
138 | });
139 | }
140 |
141 |
142 | private void showData() {
143 | String tres = "";
144 | Cursor res = easyDB.getAllData();
145 | //Cursor res = easyDB.getAllDataOrderedBy(0, false);
146 |
147 | while (res.moveToNext()) {
148 | String row = res.getString(0);
149 | String c1 = res.getString(1);
150 | String c2 = res.getString(2);
151 | tres += "Row: " + row + " C1 = " + c1 + " C2 = " + c2 + "\n";
152 | }
153 | textViewResult.setText(tres);
154 | }
155 |
156 | public void getData1(View view) {
157 | String tres = "";
158 | Cursor res = easyDB.searchInColumn(1, "1", -1);
159 |
160 | if (res != null) {
161 | while (res.moveToNext()) {
162 | String row = res.getString(0);
163 | String c1 = res.getString(1);
164 | String c2 = res.getString(2);
165 | tres += "Row: " + row + " C1 = " + c1 + " C2 = " + c2 + "\n";
166 | }
167 |
168 | textViewResult.setText(tres);
169 |
170 | } else {
171 | Toast.makeText(this, "No Data", Toast.LENGTH_SHORT).show();
172 | }
173 | }
174 | }
175 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
22 |
23 |
29 |
30 |
36 |
37 |
43 |
44 |
50 |
51 |
52 |
53 |
54 |
59 |
60 |
66 |
67 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
82 |
83 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p32929/AndroidEasySQL-Library/3d923c57b57ba46016f83366652d5e28df5b726a/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p32929/AndroidEasySQL-Library/3d923c57b57ba46016f83366652d5e28df5b726a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p32929/AndroidEasySQL-Library/3d923c57b57ba46016f83366652d5e28df5b726a/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p32929/AndroidEasySQL-Library/3d923c57b57ba46016f83366652d5e28df5b726a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p32929/AndroidEasySQL-Library/3d923c57b57ba46016f83366652d5e28df5b726a/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p32929/AndroidEasySQL-Library/3d923c57b57ba46016f83366652d5e28df5b726a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p32929/AndroidEasySQL-Library/3d923c57b57ba46016f83366652d5e28df5b726a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p32929/AndroidEasySQL-Library/3d923c57b57ba46016f83366652d5e28df5b726a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p32929/AndroidEasySQL-Library/3d923c57b57ba46016f83366652d5e28df5b726a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p32929/AndroidEasySQL-Library/3d923c57b57ba46016f83366652d5e28df5b726a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | DatabaseEasier
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/p32929/databaseeasier/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package p32929.databaseeasier;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.4.2'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/p32929/AndroidEasySQL-Library/3d923c57b57ba46016f83366652d5e28df5b726a/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Jan 12 15:47:27 BDT 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':androideasysql-library'
2 |
--------------------------------------------------------------------------------