title: SQLite database problems in android
body: <p>I have been trying to figure out how to implement a SQLite database in my app for the purpose of making a "configuration" page. 
  I have looked at many pages trying to figure it all out, but cannot seem to make it work.</p>
  
  <p><a href="https://stackoverflow.com/questions/9511727/creating-local-db-in-android-app">Creating local DB in android app</a></p>
  
  <p><a href="https://thenewcircle.com/s/post/55/sql_demo" rel="nofollow noreferrer">https://thenewcircle.com/s/post/55/sql_demo</a></p>
  
  <p><a href="http://developer.android.com/guide/topics/data/data-storage.html#db" rel="nofollow noreferrer">http://developer.android.com/guide/topics/data/data-storage.html#db</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3037767/create-sqlite-database-in-android">Create SQLite database in android</a></p>
  
  <p>are some of the pages I've been looking at. </p>
  
  <p>I want my app to save a text input from an <code>EditText</code> and then I have a "Save" <code>Button</code> at the bottom which will save the text when it's clicked. But I would like to know how since I'm not very unfamiliar with this.</p>
  
  <p>The next problem I run into is when I want to call the inputted text to be a text for a button on another layout.xml</p>
  
  <p><strong>This is my Java file</strong></p>
  
  <pre><code>package com.zimzux.test;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.content.ContentValues;
  import android.database.sqlite.*;
  
  public class tutorialOne extends Activity{
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.indstil);
  
    DictionaryOpenHelper myDictionary;
    myDictionary = new DictionaryOpenHelper(this);
  
    final SQLiteDatabase db = myDictionary.getWritableDatabase();
    final EditText indstiltxt1 = (EditText) findViewById(R.id.indstiltxt1);
    Button gem1 = (Button) findViewById(R.id.gem1);
    gem1.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v){
        ContentValues values = new ContentValues();
        values.put("id","txt");
        db.insert(indstil, null, indstiltxt1.getText());
      }
    });       
  }
  </code></pre>
  
  <p><strong>And the DictionaryOpenHelper</strong></p>
  
  <pre><code>package com.zimzux.test;
  import android.content.Context;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  import android.provider.BaseColumns;
  
  /** Helper to the database, manages versions and creation */
  public class DictionaryOpenHelper extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "indstil.db";
    private static final int DATABASE_VERSION = 1;
  
    // Table name
    public static final String TABLE = "indstil";
  
    // Columns
    public static final String ID = "id";
    public static final String TXT = "txt";
  
    public DictionaryOpenHelper(Context context) {
      super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }
  
    @Override
    public void onCreate(SQLiteDatabase db) {
      String sql = "create table " + TABLE + "( " + BaseColumns._ID
        + " integer primary key autoincrement, " + ID + " integer, "
        + TXT + " text not null);";
      db.execSQL(sql);
    }
  
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
      if (oldVersion &gt;= newVersion)
        return;
  
      String sql = null;
      if (oldVersion == 1) 
        sql = "alter table " + TABLE + " add note text;";
  
      if (oldVersion == 2)
        sql = "";
  
      if (sql != null)
        db.execSQL(sql);
    }
  </code></pre>
  
  <p>I really hope some guys in here can help me with this problem</p>