Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
••••
Malware / Trojaner / VirenPentagon data breach impacts millions of US military personnel.(01.10.2026 um 18:00 Uhr)
•
AI & KI NachrichtenRogue OpenAI agents targeted government sites.(01.10.2026 um 22:00 Uhr)
•
Malware / Trojaner / VirenThe Pentagon’s roll call.(01.10.2026 um 22:30 Uhr)
•••
IT Security NachrichtenOur Reporter Emailed the F.B.I. Hackers. They Wrote Back.(01.10.2026 um 21:57 Uhr)
•••••
Malware / Trojaner / VirenPentagon data breach impacts millions of US military personnel.(01.10.2026 um 18:00 Uhr)
•
AI & KI NachrichtenRogue OpenAI agents targeted government sites.(01.10.2026 um 22:00 Uhr)
•
Malware / Trojaner / VirenThe Pentagon’s roll call.(01.10.2026 um 22:30 Uhr)
•••
IT Security NachrichtenOur Reporter Emailed the F.B.I. Hackers. They Wrote Back.(01.10.2026 um 21:57 Uhr)
•
Intelligence View
⚡ tsecurity.de Intelligence

Log in/Sign up

//DatabaseHelper.java package com.example.yourapp; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!

//DatabaseHelper.java




package com.example.yourapp;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.*;

public class DatabaseHelper extends SQLiteOpenHelper {

public static final String DATABASE_NAME = "UserDB.db";
public static final String TABLE_NAME = "users";
public static final String COL_1 = "ID";
public static final String COL_2 = "USERNAME";
public static final String COL_3 = "PASSWORD";

public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME + " (ID INTEGER PRIMARY KEY AUTOINCREMENT, USERNAME TEXT, PASSWORD TEXT)");
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}

public boolean insertUser(String username, String password) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(COL_2, username);
contentValues.put(COL_3, password);
long result = db.insert(TABLE_NAME, null, contentValues);
return result != -1;
}

public boolean checkUser(String username, String password) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_NAME + " WHERE USERNAME=? AND PASSWORD=?", new String[]{username, password});
return cursor.getCount() > 0;
}

public boolean userExists(String username) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_NAME + " WHERE USERNAME=?", new String[]{username});
return cursor.getCount() > 0;
}
}







//LoginActivity.java




package com.example.yourapp;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import androidx.appcompat.app.AppCompatActivity;

public class LoginActivity extends AppCompatActivity {

EditText username, password;
Button loginBtn, signupRedirectBtn;
DatabaseHelper db;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);

username = findViewById(R.id.etUsername);
password = findViewById(R.id.etPassword);
loginBtn = findViewById(R.id.btnLogin);
signupRedirectBtn = findViewById(R.id.btnSignupRedirect);

db = new DatabaseHelper(this);

loginBtn.setOnClickListener(v -> {
String user = username.getText().toString();
String pass = password.getText().toString();

if (db.checkUser(user, pass)) {
Toast.makeText(LoginActivity.this, "Login Successful", Toast.LENGTH_SHORT).show();
startActivity(new Intent(LoginActivity.this, MainActivity.class));
finish();
} else {
Toast.makeText(LoginActivity.this, "Invalid credentials", Toast.LENGTH_SHORT).show();
}
});

signupRedirectBtn.setOnClickListener(v -> startActivity(new Intent(LoginActivity.this, SignupActivity.class)));
}
}







//SignupActivity




package com.example.yourapp;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import androidx.appcompat.app.AppCompatActivity;

public class SignupActivity extends AppCompatActivity {

EditText username, password, confirmPassword;
Button signupBtn;
DatabaseHelper db;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);

username = findViewById(R.id.etUsernameSignup);
password = findViewById(R.id.etPasswordSignup);
confirmPassword = findViewById(R.id.etConfirmPassword);
signupBtn = findViewById(R.id.btnSignup);

db = new DatabaseHelper(this);

signupBtn.setOnClickListener(v -> {
String user = username.getText().toString();
String pass = password.getText().toString();
String cpass = confirmPassword.getText().toString();

if (user.equals("") || pass.equals("") || cpass.equals("")) {
Toast.makeText(SignupActivity.this, "All fields are required", Toast.LENGTH_SHORT).show();
} else if (!pass.equals(cpass)) {
Toast.makeText(SignupActivity.this, "Passwords do not match", Toast.LENGTH_SHORT).show();
} else if (db.userExists(user)) {
Toast.makeText(SignupActivity.this, "User already exists", Toast.LENGTH_SHORT).show();
} else {
if (db.insertUser(user, pass)) {
Toast.makeText(SignupActivity.this, "Signup Successful", Toast.LENGTH_SHORT).show();
startActivity(new Intent(SignupActivity.this, LoginActivity.class));
finish();
} else {
Toast.makeText(SignupActivity.this, "Signup Failed", Toast.LENGTH_SHORT).show();
}
}
});
}
}







//activity_login.xml




<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="24dp"
android:gravity="center">

<EditText
android:id="@+id/etUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username" />

<EditText
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword" />

<Button
android:id="@+id/btnLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login" />

<Button
android:id="@+id/btnSignupRedirect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No account? Sign up" />

</LinearLayout>







//activity_signup.xml




<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="24dp"
android:gravity="center">

<EditText
android:id="@+id/etUsernameSignup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Username" />

<EditText
android:id="@+id/etPasswordSignup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword" />

<EditText
android:id="@+id/etConfirmPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Confirm Password"
android:inputType="textPassword" />

<Button
android:id="@+id/btnSignup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign Up" />

</LinearLayout>







Steps to Integrate Login/Signup



🔹 1. Add Activities to AndroidManifest.xml

Open AndroidManifest.xml and add:




<application ... >

<activity android:name=".MainActivity" />
<activity android:name=".SignupActivity" />
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>







This makes LoginActivity the first screen when the app launches.




  1. Connect to Your Main App Screen
    Let’s say your main screen is MainActivity.java, already existing. In LoginActivity.java, modify this part:




if (db.checkUser(user, pass)) {
Toast.makeText(LoginActivity.this, "Login Successful", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra("username", user); // optional
startActivity(intent);
finish(); // prevent back navigation to login
}








  1. Access the Logged-in User in MainActivity (Optional)
    In MainActivity.java, you can get the logged-in username:




String username = getIntent().getStringExtra("username");
TextView welcome = findViewById(R.id.tvWelcome);
welcome.setText("Welcome, " + username + "!");








  1. (Optional) Add a Logout Button in MainActivity
    To go back to login screen:




Button logoutBtn = findViewById(R.id.btnLogout);
logoutBtn.setOnClickListener(v -> {
Intent intent = new Intent(MainActivity.this, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); // clear back stack
startActivity(intent);
});








  1. Add the DatabaseHelper.java to Your java Folder

    Just right-click your java package, choose New > Java Class, name it DatabaseHelper, and paste the provided code.


  2. Add XML Layouts

    Copy:

    activity_login.xml → res/layout/activity_login.xml

    activity_signup.xml → res/layout/activity_signup.xml

    Use the layout editor or just paste the XML directly.


🔍 CTI & Forensik

Cyber Threat Intelligence & Forensik

Bedrohungsgraph · ATT&CK-Mapping · Exploit-Belege
CTI Threat Relationship Graph
Akteure · Techniken · Beziehungen
2 Knoten · 1 Relationen
CVE / Incident Threat Actor Software MITRE ATT&CK CWE Weakness IoC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Log in/Sign up

Thematisch verwandte Begriffe: inSign · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag