Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Carrentals_james_clarke
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
james.clarke2
Carrentals_james_clarke
Commits
235cf973
Commit
235cf973
authored
May 19, 2020
by
james.clarke2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete myDBConnector.java
parent
25f664b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
122 deletions
+0
-122
myDBConnector.java
myDBConnector.java
+0
-122
No files found.
myDBConnector.java
deleted
100644 → 0
View file @
25f664b3
package
com
.
example
.
carrentals
;
import
android.content.ContentValues
;
import
android.content.Context
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteOpenHelper
;
// Terms for the structure
public
class
myDBConnector
extends
SQLiteOpenHelper
{
private
static
final
int
DB_VERSION
=
1
;
private
static
final
String
DB_NAME
=
"Registration.db"
;
private
static
final
String
TABLE_Users
=
"Users"
;
private
static
final
String
COLUMN_ID
=
"UsersID"
;
private
static
final
String
COLUMN_Name
=
"Name"
;
private
static
final
String
COLUMN_UserName
=
"UserName"
;
private
static
final
String
COLUMN_Password
=
"Password"
;
public
myDBConnector
(
Context
context
,
String
name
,
SQLiteDatabase
.
CursorFactory
factory
,
int
version
)
{
super
(
context
,
DB_NAME
,
factory
,
DB_VERSION
);
}
@Override
public
void
onCreate
(
SQLiteDatabase
db
)
{
String
Create_table
=
"CREATE TABLE "
+
TABLE_Users
+
"("
+
COLUMN_ID
+
"INTEGER PRIMARY KEY,"
+
COLUMN_Name
+
" TEXT,"
+
COLUMN_UserName
+
" TEXT,"
+
COLUMN_Password
+
" INTEGER"
+
")"
;
db
.
execSQL
(
Create_table
);
}
@Override
public
void
onUpgrade
(
SQLiteDatabase
db
,
int
oldVersion
,
int
newVersion
)
{
}
// End of the class myDBCONNECTOR
public
void
addNewUser
(
String
name
,
String
userName
,
String
password
)
{
ContentValues
values
=
new
ContentValues
();
values
.
put
(
COLUMN_Name
,
name
);
values
.
put
(
COLUMN_UserName
,
userName
);
values
.
put
(
COLUMN_Password
,
password
);
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
db
.
insert
(
TABLE_Users
,
null
,
values
);
db
.
close
();
}
public
boolean
checkLogin
(
String
username
,
String
password
)
{
boolean
result
=
false
;
String
query
=
"Select * FROM "
+
TABLE_Users
+
" WHERE "
+
COLUMN_UserName
+
" = \""
+
username
+
"\""
;
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
Cursor
cursor
=
db
.
rawQuery
(
query
,
null
);
if
(
cursor
.
moveToFirst
())
{
if
(
cursor
.
getString
(
3
).
equals
(
password
))
{
result
=
true
;
}
}
else
{
result
=
false
;
}
cursor
.
close
();
db
.
close
();
return
result
;
}
public
String
findUser
(
String
Username
)
{
String
s
=
null
;
String
query
=
"Select * From"
+
TABLE_Users
+
"WHERE "
+
COLUMN_UserName
+
"= \""
+
Username
+
"\""
;
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
Cursor
cursor
=
db
.
rawQuery
(
query
,
null
);
if
(
cursor
.
moveToFirst
())
{
s
=
Integer
.
parseInt
(
cursor
.
getString
(
0
))
+
cursor
.
getString
(
1
)
+
cursor
.
getString
(
2
)
+
cursor
.
getString
(
3
);
}
cursor
.
close
();
db
.
close
();
return
s
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment