Search in sources :

Example 1 with AlphaTourDbHelper

use of com.example.alphatour.dblite.AlphaTourDbHelper in project AlphaTour by Frank99DG.

the class CreateConstraintsWizard method getIdZone.

private String getIdZone(Element elm) {
    String idZone = "";
    AlphaTourDbHelper dbAlpha = new AlphaTourDbHelper(getContext());
    SQLiteDatabase db = dbAlpha.getReadableDatabase();
    Cursor cursor = db.rawQuery(CommandDbAlphaTour.Command.SELECT_ID_ZONE, new String[] { elm.getZoneRif() });
    if (cursor.moveToFirst()) {
        idZone = cursor.getString(cursor.getColumnIndexOrThrow(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_ZONE_ID));
    }
    return idZone;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) AlphaTourDbHelper(com.example.alphatour.dblite.AlphaTourDbHelper) ElementString(com.example.alphatour.oggetti.ElementString) Cursor(android.database.Cursor)

Example 2 with AlphaTourDbHelper

use of com.example.alphatour.dblite.AlphaTourDbHelper in project AlphaTour by Frank99DG.

the class UpdateProfileActivity method updateUserOnDbLocal.

public int updateUserOnDbLocal(String Name, String Surname, String DateOfBirth, String Username, String Email, String EmailLocal) {
    AlphaTourDbHelper dbAlpha = new AlphaTourDbHelper(this);
    // recupero idUtente
    SQLiteDatabase db = dbAlpha.getReadableDatabase();
    Cursor cursor = db.rawQuery(CommandDbAlphaTour.Command.SELECT_USER_PROFILE, new String[] { emailLocal });
    if (cursor.moveToFirst()) {
        idUtenteLocal = cursor.getString(cursor.getColumnIndexOrThrow(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_ID));
    }
    // aggiornamento dati utente
    db = dbAlpha.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_NAME, Name);
    values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_SURNAME, Surname);
    values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_DATE_BIRTH, DateOfBirth);
    values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_USERNAME, Username);
    values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_EMAIL, Email);
    return db.update(AlphaTourContract.AlphaTourEntry.NAME_TABLE_USER, values, AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_ID + CommandDbAlphaTour.Command.EQUAL + CommandDbAlphaTour.Command.VALUE, new String[] { idUtenteLocal });
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) AlphaTourDbHelper(com.example.alphatour.dblite.AlphaTourDbHelper) Cursor(android.database.Cursor)

Example 3 with AlphaTourDbHelper

use of com.example.alphatour.dblite.AlphaTourDbHelper in project AlphaTour by Frank99DG.

the class ProfileActivity method saveImageProfileOnDbLocal.

// salva l'uri dell'immagine di profilo
private int saveImageProfileOnDbLocal(Uri uri) {
    AlphaTourDbHelper dbAlpha = new AlphaTourDbHelper(this);
    // recupero idUtente
    SQLiteDatabase db = dbAlpha.getReadableDatabase();
    Cursor cursor = db.rawQuery(CommandDbAlphaTour.Command.SELECT_USER_PROFILE, new String[] { email });
    if (cursor.moveToFirst()) {
        idUtenteLocal = cursor.getString(cursor.getColumnIndexOrThrow(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_ID));
    }
    db = dbAlpha.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_IMAGE, uri.toString());
    return db.update(AlphaTourContract.AlphaTourEntry.NAME_TABLE_USER, values, AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_ID + CommandDbAlphaTour.Command.EQUAL + CommandDbAlphaTour.Command.VALUE, new String[] { idUtenteLocal });
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) AlphaTourDbHelper(com.example.alphatour.dblite.AlphaTourDbHelper) Cursor(android.database.Cursor)

Example 4 with AlphaTourDbHelper

use of com.example.alphatour.dblite.AlphaTourDbHelper in project AlphaTour by Frank99DG.

the class RegisterActivity method saveUserOnDbLocal.

public long saveUserOnDbLocal(String Name, String Surname, String DateBirth, String Username, String Email) {
    AlphaTourDbHelper dbAlpha = new AlphaTourDbHelper(this);
    SQLiteDatabase db = dbAlpha.getWritableDatabase();
    ContentValues values = new ContentValues();
    long newRowId;
    // valori.put(AlphaTourContract.AlphaTourEntry.NOME_COLONNA_UTENTE_ID,2);
    values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_NAME, Name);
    values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_SURNAME, Surname);
    values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_DATE_BIRTH, DateBirth);
    values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_USERNAME, Username);
    values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_EMAIL, Email);
    values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_USER_IMAGE, "null");
    newRowId = db.insert(AlphaTourContract.AlphaTourEntry.NAME_TABLE_USER, AlphaTourContract.AlphaTourEntry.COLUMN_NAME_NULLABLE, values);
    return newRowId;
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) AlphaTourDbHelper(com.example.alphatour.dblite.AlphaTourDbHelper)

Example 5 with AlphaTourDbHelper

use of com.example.alphatour.dblite.AlphaTourDbHelper in project AlphaTour by Frank99DG.

the class CreateConstraintsWizard method saveObjectsLocal.

private long saveObjectsLocal(List<Element> elementList) {
    long newRowId = -1;
    AlphaTourDbHelper dbAlpha = new AlphaTourDbHelper(getContext());
    SQLiteDatabase db = dbAlpha.getWritableDatabase();
    ContentValues values = new ContentValues();
    for (int i = 0; i < elementList.size(); i++) {
        Element elm = elementList.get(i);
        String idZone = getIdZone(elm);
        values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_ELEMENT_ID_ZONE, idZone);
        values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_ELEMENT_NAME, elm.getTitle());
        values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_ELEMENT_DESCRIPTION, elm.getDescription());
        values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_ELEMENT_PHOTO, elm.getPhoto().toString());
        values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_ELEMENT_QR_CODE, elm.getQrData());
        values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_ELEMENT_LOAD, load);
        newRowId = db.insert(AlphaTourContract.AlphaTourEntry.NAME_TABLE_ELEMENT, AlphaTourContract.AlphaTourEntry.COLUMN_NAME_NULLABLE, values);
    }
    return newRowId;
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Element(com.example.alphatour.oggetti.Element) AlphaTourDbHelper(com.example.alphatour.dblite.AlphaTourDbHelper) ElementString(com.example.alphatour.oggetti.ElementString) Constraint(com.example.alphatour.oggetti.Constraint)

Aggregations

SQLiteDatabase (android.database.sqlite.SQLiteDatabase)11 AlphaTourDbHelper (com.example.alphatour.dblite.AlphaTourDbHelper)11 ContentValues (android.content.ContentValues)8 Cursor (android.database.Cursor)5 ElementString (com.example.alphatour.oggetti.ElementString)3 Constraint (com.example.alphatour.oggetti.Constraint)2 Element (com.example.alphatour.oggetti.Element)1 ZoneChoosed (com.example.alphatour.oggetti.ZoneChoosed)1