mardi 29 septembre 2015

Database File not Creating Android

I'm implementing a software on Android platform and i'm using SQLLite Database for it. I've put every codes about to connect to database in DBUserAdapter Class and Other loginScreen and registerScreen classes have the codings for login and register methods seperately.

When i clicked the Register button the Log showing the Database File not Available. Can anyone help me to solve this problem. Thanks in Advance.. :)

This is my DBUserAdapter.java Class


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import java.sql.SQLException;

/**
* Created by Miuranga Salgado on 9/29/2015.
*/
public class DBUserAdapter {
public static final String KEY_ROWID = "_id";
public static final String KEY_USERNAME = "username";
public static final String KEY_PASSWORD = "password";
public static final String KEY_PASSHINT = "passHint";
public static final String TAG = "DBAdapter";

public static final String DATABASE_NAME = "usersdb";
public static final String DATABASE_TABLE = "userInfo";
public static final int DATABASE_VERSION = 1;

public static final String DATABASE_CREATE = "CREATE TABLE "+DATABASE_TABLE+"(_id INTEGER PRIMARY KEY AUTOINCREMENT, username varchar(100)TEXT NOT NULL, password varchar(100)TEXT NOT NULL, passHint varchar(100)TEXT NOT NULL);";

private Context context = null;
private DatabaseHelper dbHelper;
public SQLiteDatabase db;

public DBUserAdapter(Context context){
    this.context = context;
    dbHelper = new DatabaseHelper(context);
}

private static class DatabaseHelper extends SQLiteOpenHelper{
    DatabaseHelper(Context context){
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DATABASE_CREATE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.w(TAG, "Upgrading Database from Version "+oldVersion+" to "+newVersion+", Which will Destroy all old Data");
        db.execSQL("DROP TABLE IF EXISTS userInfo");
        onCreate(db);
    }
}

public void open() throws SQLException{
    db = dbHelper.getWritableDatabase();
}

public void close(){
    db.close();
}

public SQLiteDatabase getDatabaseInstance(){
    return db;
}

public boolean AddUser(String username, String password, String passHint){
    try {
        ContentValues initialValues = new ContentValues();
        initialValues.put(KEY_USERNAME, username);
        initialValues.put(KEY_PASSWORD, password);
        initialValues.put(KEY_PASSHINT, passHint);
        db.insert(DATABASE_TABLE, null, initialValues);
        db.close();
        return true;
    }
    catch (Exception e){
        e.printStackTrace();
    }
    return false;
}

public boolean Login(String username, String password) throws SQLException{
    Cursor cursor = db.rawQuery("SELECT * FROM " + DATABASE_TABLE + " WHERE username=? AND password=?", new String[]{username, password});
    if(cursor != null){
        if (cursor.getCount() > 0){
            return true;
        }
    }
    return false;
}

public String getPassword(String userName){
    Cursor cursor = db.query(DATABASE_TABLE, null, "username=?", new String[]{userName}, null, null, null);
    if (cursor.getCount()<1){
        cursor.close();
        return "NOT EXIST";
    }
    cursor.moveToFirst();
    String password = cursor.getString(cursor.getColumnIndex("PASSWORD"));
    cursor.close();
    return password;
}

public boolean register(String username, String password, String passHint)throws SQLException{
    Cursor cursor = db.rawQuery("INSERT INTO "+DATABASE_TABLE+" VALUES('?', '?', '?', '?');", new String[]{username, password, passHint});
    if(cursor != null){
        if(cursor.getCount() > 0){
            return true;
        }
    }
    return false;
}
}


This is my loginScreen.java Class

public class loginScreen extends Activity {

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

    final EditText loginUser = (EditText) findViewById(R.id.inputUser);
    final EditText loginPass = (EditText) findViewById(R.id.inputPass);

    Button btnLogin = (Button) findViewById(R.id.loginBtn);
    Button btnRegister = (Button) findViewById(R.id.registerBtn);
    btnLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String username = loginUser.getText().toString();
            String password = loginPass.getText().toString();
            //String relPassword = userAdapter.getPassword(username);
            try {
                if (username.length() > 0 && password.length() > 0) {
                    DBUserAdapter dbAdapter = new DBUserAdapter(loginScreen.this);
                    dbAdapter.open();
                    if (dbAdapter.Login(username, password)) {
                        Toast.makeText(loginScreen.this, "Successfully Logged In", Toast.LENGTH_LONG).show();

                    } else {
                        Toast.makeText(loginScreen.this, "Invalid Username or Password", Toast.LENGTH_LONG).show();
                    }
                    dbAdapter.close();
                }
            } catch (Exception e) {
                Toast.makeText(loginScreen.this, e.getMessage(), Toast.LENGTH_LONG).show();
            }
            //if(password.equals(relPassword)) {
            //    Toast.makeText(loginScreen.this, "Successfully Logged In", Toast.LENGTH_LONG).show();
            //}
            //else {
            //    Toast.makeText(loginScreen.this, "Sorry, Invalid Username or Password", Toast.LENGTH_LONG).show();
            //}
        }
    });

    btnRegister.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(loginScreen.this, registerScreen.class);
            startActivity(intent);
        }
    });
}
}


This is registerScreen.java Class


public class registerScreen extends Activity{

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

    final EditText regUsername = (EditText)findViewById(R.id.regUserName);
    final EditText regPassword = (EditText)findViewById(R.id.regPassword);
    final EditText regPassHint = (EditText)findViewById(R.id.regPassHint);

    Button regButton = (Button)findViewById(R.id.btnCreateAcc);
    regButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String username = regUsername.getText().toString();
            String password = regPassword.getText().toString();
            String passHint = regPassHint.getText().toString();
            try {
                if (username.length() > 0 && password.length() > 0 && passHint.length() > 0){
                    DBUserAdapter dbAdapter = new DBUserAdapter(registerScreen.this);
                    dbAdapter.open();
                    if(dbAdapter.AddUser(username, password, passHint)){
                        Toast.makeText(registerScreen.this, "You're Registered Successfully", Toast.LENGTH_LONG).show();
                    }
                    else {
                        Toast.makeText(registerScreen.this, "User Not Registered", Toast.LENGTH_LONG).show();
                    }
                    dbAdapter.close();
                }
            }
            catch (Exception e){
                Toast.makeText(registerScreen.this, e.getMessage(), Toast.LENGTH_LONG).show();
            }
            }

    });
}
}


This is Error Log


      09-30 00:28:57.821       482-482/supprioritizer.warnerit.com.supermarketprioritizer E/SQLiteLog﹕ (1) no such table: userInfo
09-30 00:28:57.829      482-482/supprioritizer.warnerit.com.supermarketprioritizer E/SQLiteDatabase﹕ Error inserting passHint=123 password=123 username=Randula
    android.database.sqlite.SQLiteException: no such table: userInfo (code 1): , while compiling: INSERT INTO userInfo(passHint,password,username) VALUES (?,?,?)
            at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
            at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:891)
            at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:502)
            at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
            at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
            at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
            at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)
            at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341)
            at supprioritizer.warnerit.com.supermarketprioritizer.DBUserAdapter.AddUser(DBUserAdapter.java:73)
            at supprioritizer.warnerit.com.supermarketprioritizer.registerScreen$1.onClick(registerScreen.java:37)
            at android.view.View.performClick(View.java:4797)
            at android.view.View$PerformClick.run(View.java:19899)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5309)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)

Android not displaying data from database

I created a very simple application which allows the user to save emergency information into a database and then displays it on a different screen. The information the user can save is first name, blood type, contact number, phone number and relationship type.

However the problem is that the application is not displaying all of the information. It is only displaying the first name. I believe the cursor is not moving onto the next row, so I think the problem is in the code below:

    public String databaseToString(){
    String dbString = "";
    SQLiteDatabase db = getWritableDatabase();
    //Every Column and row
    String query = "SELECT * FROM " + TABLE_PRODUCTS + " WHERE 1";

    //Cursor points to a location in your results
    //First row point here, second row point here

    Cursor c = db.rawQuery(query, null);
    c.moveToFirst();

    while(!c.isAfterLast()){
        //Extracts first name and adds to string
        if(c.getString(c.getColumnIndex("firstName"))!=null){
            dbString += c.getString(c.getColumnIndex("firstName"));
            c.moveToNext();
            /*
             * Displaying all other columns 
             */
        }
    }
    db.close();
    return dbString;
}

Here is the full Code:

Database Class:

package com.example.androidsimpledbapp1;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.Cursor;
import android.content.Context;
import android.content.ContentValues;

public class MyDBHandler extends SQLiteOpenHelper {

/*
 * Class for Working with DB 
 */

//Update each time DB structure changes e.g. adding new property
private static final int DATABASE_VERSION =1;
//DB Name
private static final String DATABASE_NAME = "details.db";
//Table name
public static final String  TABLE_PRODUCTS = "products";
//DB Columns 
public static final String  COLUMN_ID = "_Id";
public static final String  COLUMN_PERSONNAME  = "firstName";
public static final String  COLUMN_PERSONBLOOD  = "bloodType";
public static final String  COLUMN_PERSONCONTACT  = "contactName";
public static final String  COLUMN_PERSONNUMBER  = "phoneNumber";
public static final String  COLUMN_PERSONRELATION = "relationship";

//Constructor
/*
 * Passing information to super class in SQL
 * Context is background information 
 * name of db 
 * Database version
 */
public MyDBHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version){
    super(context, DATABASE_NAME, factory, DATABASE_VERSION);
}

/*
 * What to do first time when you create DB
 * Creates the table the very first time
 * (non-Javadoc)
 * @see android.database.sqlite.SQLiteOpenHelper#onCreate(android.database.sqlite.SQLiteDatabase)
 * Remember to use Commas as shown below
 */
@Override
public void onCreate(SQLiteDatabase db){
    String query = "CREATE TABLE "+ TABLE_PRODUCTS + "(" +
            COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "+
            COLUMN_PERSONNAME + " TEXT, "+
            COLUMN_PERSONBLOOD + " TEXT, "+
            COLUMN_PERSONCONTACT + " TEXT, "+
            COLUMN_PERSONNUMBER + " TEXT, " +
            COLUMN_PERSONRELATION + " TEXT " +
            ");";
    //Execute the query
    db.execSQL(query);
}

/*
 * If ever upgrading DB call this method
 * (non-Javadoc)
 * @see android.database.sqlite.SQLiteOpenHelper#onUpgrade(android.database.sqlite.SQLiteDatabase, int, int)
 */
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
    //Delete the current table
    db.execSQL("DROP TABLE IF EXISTS" + TABLE_PRODUCTS);
    //create new table 
    onCreate(db);
}

//Add new row to the database
public void addProduct(Details details){
    //Built in class - set values for different columns 
    //Makes inserting rows quick and easy
    ContentValues values = new ContentValues();
    values.put(COLUMN_PERSONNAME, details.get_firstName());
    values.put(COLUMN_PERSONBLOOD, details.get_bloodType());
    values.put(COLUMN_PERSONCONTACT, details.get_contactName());
    values.put(COLUMN_PERSONNUMBER, details.get_phoneNumber());
    values.put(COLUMN_PERSONRELATION, details.get_relationship());
    SQLiteDatabase db = getWritableDatabase();
    db.insert(TABLE_PRODUCTS, null, values);
    db.close();
}

/*Table was deleted*/
public void deleteProducts(){
    SQLiteDatabase db = getWritableDatabase();      
    db.delete(TABLE_PRODUCTS, null, null);
}

//Take DB and Convert to String 
public String databaseToString(){
    String dbString = "";
    SQLiteDatabase db = getWritableDatabase();
    //Every Column and row
    String query = "SELECT * FROM " + TABLE_PRODUCTS + " WHERE 1";

    //Cursor points to a location in your results
    //First row point here, second row point here

    Cursor c = db.rawQuery(query, null);
    c.moveToFirst();

    while(!c.isAfterLast()){
        //Extracts first name and adds to string
        if(c.getString(c.getColumnIndex("firstName"))!=null){
            dbString += c.getString(c.getColumnIndex("firstName"));
            c.moveToNext();
            /*
             * Displaying all other columns 
             */
        }
    }
    db.close();
    return dbString;
}
  }

Details Class:

package com.example.androidsimpledbapp1;

public class Details {

//primary key
private int _id;
//Properties 
private String _firstName;
private String _bloodType;
private String _contactName;
private String _phoneNumber;
private String _relationship;

//Dont Have to Enter Everything each time
public Details(){

}

public Details(String firstName){
    this.set_firstName(firstName);
}

//Passing in details 
//Setting values from the user 
public Details(String firstName, String bloodType,
        String contactName, String phoneNumber,
        String relationship){
    this.set_firstName(firstName);
    this.set_bloodType(bloodType);
    this.set_contactName(contactName);
    this.set_phoneNumber(phoneNumber);
    this.set_relationship(relationship);

}

//Retrieve the data 
public int get_id() {
    return _id;
}

//Setter allows to give property
public void set_id(int _id) {
    this._id = _id;
}

public String get_firstName() {
    return _firstName;
}

public void set_firstName(String _firstName) {
    this._firstName = _firstName;
}

public String get_bloodType() {
    return _bloodType;
}

public void set_bloodType(String _bloodType) {
    this._bloodType = _bloodType;
}

public String get_contactName() {
    return _contactName;
}

public void set_contactName(String _contactName) {
    this._contactName = _contactName;
}

public String get_phoneNumber() {
    return _phoneNumber;
}

public void set_phoneNumber(String _phoneNumber) {
    this._phoneNumber = _phoneNumber;
}

public String get_relationship() {
    return _relationship;
}

public void set_relationship(String _relationship) {
    this._relationship = _relationship;
}
}

Edit Screen - The screen where the user adds the data into the DB, upon pressing save the all the database information should display on the main activity

package com.example.androidsimpledbapp1;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class EditScreen extends Activity {


EditText firstNameInput;
EditText bloodTypeInput;
EditText contacNameInput;
EditText phoneNumberInput;
EditText relationshipInput;
MyDBHandler dbHandler;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_screen);
    //Setting EditTexts 
    firstNameInput = (EditText) findViewById(R.id.inputname);
    bloodTypeInput = (EditText) findViewById(R.id.inputblood);
    contacNameInput = (EditText) findViewById(R.id.inputcontact);
    phoneNumberInput = (EditText) findViewById(R.id.inputnum);
    relationshipInput = (EditText) findViewById(R.id.inputraltion);
    //Setting DbHandler object 
    dbHandler = new MyDBHandler(this, null, null, 1);

}

public void saveMe(View v){
    /*
     * Making a new object 
     * Object takes 5 parameters 
     */
    Details detail = new Details(firstNameInput.getText().toString(),
            bloodTypeInput.getText().toString(),
            contacNameInput.getText().toString(),
            phoneNumberInput.getText().toString(),
            relationshipInput.getText().toString());
    dbHandler.addProduct(detail);

    //Sending Text To Main Activity
    String dbString = dbHandler.databaseToString();
    Intent myIntent = new Intent(v.getContext(),MainActivity.class);
    myIntent.putExtra("mytext",dbString);
    startActivity(myIntent);
    //End of Sending to Main Activity


    //Setting the text in Edit Text
    firstNameInput.setText(dbString);
}


public void clearBtnPressed(View v){
    dbHandler.deleteProducts();
}
  }

MainActivity - This screen displays the data

package com.example.androidsimpledbapp1;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;



public class MainActivity extends Activity {

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

    //Grabs the TextView 
    mTextView = (TextView)findViewById(R.id.dbname);
    mTextView.setText(getIntent().getStringExtra("mytext"));
}

//Changing Activity
public void editBtnPressed(View v){
    Intent intent = new Intent(MainActivity.this, EditScreen.class);
    startActivity(intent);
}

 }

How to get the Max value SQLite Android

Trying to get the maximum id in my TABLE_GOALS

public String getLatestGoal(){
    SQLiteDatabase db=dbhandler.getWritableDatabase();

    //columns
    Cursor cursor=db.query(MyDBHandler.TABLE_GOALS, null, "SELECT MAX("+MyDBHandler.COLUMN_ID+"))", null, null, null, null);
    StringBuffer buffer = new StringBuffer();
    while(cursor.moveToNext()){
        int index1=cursor.getColumnIndex(MyDBHandler.COLUMN_ID);
        String max_id=cursor.getString(index1);
        buffer.append(max_id);
    }
    return buffer.toString();

}

I can't get the maximum value and i don't know why. Sorry, newbie here in Android.

Leading numbers in table name with dbWriteTable (RSQLite) causes error

I am trying to write a table to a database using RSQLite:

library(RSQLite)

#Create SQL Database
dbfile <- "Testdb.db"
sqlite <- dbDriver("SQLite")
SQLiteChannel <- dbConnect(sqlite, dbfile)

This works fine:

dbWriteTable(SQLiteChannel,name = "mtcars",value = mtcars)

> head(dbReadTable(SQLiteChannel,"mtcars"))
                   mpg cyl disp  hp drat    wt  qsec vs am gear carb
Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1

However, if I add leading numbers to the table name:

dbWriteTable(SQLiteChannel,name = "2015_mtcars",value = mtcars)

Error in sqliteSendQuery(con, statement, bind.data) : 
  error in statement: unrecognized token: "2015_mtcars"

To my knowledge, leading numbers are allowed in table names for sqlite, but all the examples in documentation have no leading numbers.

Any idea what is going on, or how I can name my tables this way using dbWriteTable?

Note: The database and the tables did not exist before running this code, so it should be completely reproducable.

Copied CoreData sqlite3 file, but copy doesn't show any tables

I've got a very data sensitive app and just to be absolutely sure there is no data lost when app updates are made and the CoreData sqlite file is upgraded, we grab a copy of the CoreData .sqlite file and upload it to the server. That part appears to be working just fine. The file comes through exactly the same size and when I diff it with the original they are identical.

However, when I open the original .sqlite file and issue a .tables command, I see all of the appropriate tables, but when I open the copied .sqlite file and issue a .tables command I get nothing.

Using the directory associated with the simulator, I can use sqlite3 to check the original .sqlite file and the pre-upload copy of the file and I see all of the tables:

Kenny-iMac:~/Library/Developer/CoreSimulator/Devices/C9E435A0-F438-45B0-914A-0E586A12589B/data/Containers/Data/Application/0B0C4673-99AF-4EEF-A9BE-654C155BB167/Documents$ sqlite3 MyApp.sqlite
SQLite version 3.8.5 2014-08-15 22:37:57
Enter ".help" for usage hints.
sqlite> .tables
ZBASECLONABLEENTITY   ZREPORTCONFIGURATION  Z_MODELCACHE        
ZCHANGERECORD         Z_3LABELS             Z_PRIMARYKEY        
ZOWNER                Z_METADATA          
sqlite> .quit
Kenny-iMac:~/Library/Developer/CoreSimulator/Devices/C9E435A0-F438-45B0-914A-0E586A12589B/data/Containers/Data/Application/0B0C4673-99AF-4EEF-A9BE-654C155BB167/Documents$ sqlite3 backup.MyApp.v1.0-to-v1.1.3.1234567.sqlite 
SQLite version 3.8.5 2014-08-15 22:37:57
Enter ".help" for usage hints.
sqlite> .tables
ZBASECLONABLEENTITY   ZREPORTCONFIGURATION  Z_MODELCACHE        
ZCHANGERECORD         Z_3LABELS             Z_PRIMARYKEY        
ZOWNER                Z_METADATA          
sqlite> .quit
Kenny-iMac:~/Library/Developer/CoreSimulator/Devices/C9E435A0-F438-45B0-914A-0E586A12589B/data/Containers/Data/Application/0B0C4673-99AF-4EEF-A9BE-654C155BB167/Documents$ 

However, when I use sqlite3 on the uploaded file, I don't see any tables:

Kenny-iMac:~/Sites/http://ift.tt/1iZrV12 sqlite3 backup.MyApp.v1.0-to-v1.1.3.1234567.sqlite
SQLite version 3.8.5 2014-08-15 22:37:57
Enter ".help" for usage hints.
sqlite> .tables
sqlite> .quit
Kenny-iMac:~/Sites/http://ift.tt/1iZrV12

The filesize of the original and the backup file are the same (880640):

Kenny-Mac: [simulator directory] $ ls -l
total 3648
-rw-r--r--  1 kenny  staff  921600 Sep 29 08:52 MyApp.sqlite
-rw-r--r--  1 kenny  staff   32768 Sep 29 08:51 MyApp.sqlite-shm
-rw-r--r--  1 kenny  staff       0 Sep 29 08:52 MyApp.sqlite-wal
-rw-r--r--  1 kenny  staff  880640 Sep 24 16:00 backup.MyApp.v1.0-to-v1.1.3.1234567.sqlite
-rw-r--r--  1 kenny  staff   32768 Sep 29 11:12 backup.MyApp.v1.0-to-v1.1.3.1234567.sqlite-shm
-rw-r--r--  1 kenny  staff       0 Sep 29 08:52 backup.MyApp.v1.0-to-v1.1.3.1234567.sqlite-wal
Kenny-Mac: [simulator directory] $

The upload copy is the same size (880640):

Kenny-iMac:~/Sites/http://ift.tt/1Ww1v5g ls -l
total 1720
-rw-r--r--  1 _www  wheel  880640 Sep 29 08:44 backup.HerdBoss.v1.0-to-v1.1.3.1234567.sqlite.oid.0.unverified
Kenny-iMac:~/Sites/http://ift.tt/1Ww1v5g

I also compared them with diff and they are identical.

Why can't I see the tables in my backup copy?

Different results for a similar queries depends on format of date string in sqlite3

I have two tables in sqlite3:

sqlite> create table date_1 (date text);
sqlite> create table date_2 (date text);

Each table contains three rows with dates written in different formats:

sqlite> select * from date_1;
28.09.2015
28.08.2015
29.08.2015
sqlite> select * from date_2;
2015-09-28
2015-08-28
2015-08-29

My current date is:

sqlite> select date('now');
2015-09-29

Why do I have a different results for the next similar queries?

sqlite> select * from date_1 where date < strftime('%d.%m.%Y', 'now', '-1 day');
28.08.2015
sqlite> select * from date_2 where date < strftime('%Y-%m-%d', 'now', '-1 day');
2015-08-28
2015-08-29

Why first query don't returns '29.08.2015' too?

Showing the rest of an SQLite row?

I have printed out a database, but i need to make it clickable to show the rest of that row.

    public String dbToString(){
    String dbString = "";
    SQLiteDatabase db = getWritableDatabase();
    String query = "SELECT * FROM " + TABLE_RECIPES + " WHERE 1;";

    Cursor c = db.rawQuery(query, null);
    c.moveToFirst();

    while(!c.isAfterLast()){
        if (c.getString(c.getColumnIndex("recipeTitle")) != null) {
            dbString += c.getString(c.getColumnIndex("recipeTitle"));
            dbString += "\n";
        }
        c.moveToNext();
    }
    db.close();
    c.close();
    return dbString;
}

I basicly want to make it when the user presses the recipeTitle it will show "recipeIMG", "recipeIngredients" and "recipeProgress"