jeudi 31 mars 2016

how i can insert more rows in this sqlite database and how can i use Autocomplete Textview from it

how i can insert more rows in this sqlite database and how can i use Autocomplete Textview to select longitude and latitude from it this sqlite is very small and i what also to ask if this sqlite i can connect it with json and with mysql server

public class MainActivity3 extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_activity3);
    SQLiteDatabase db;
    db = openOrCreateDatabase( "Temp.db"        , SQLiteDatabase.CREATE_IF_NECESSARY        , null          );
    try {
        final String CREATE_TABLE_CONTAIN = "CREATE TABLE IF NOT EXISTS tbl_Contain ("
                + "ID INTEGER primary key AUTOINCREMENT,"
                + "FNAME TEXT,"
                + "longitude DOUUBLE,"
                + "latitude DOUUBLE,"
                + "info TEXT," + "notes TEXT);";
        db.execSQL(CREATE_TABLE_CONTAIN);
        Toast.makeText(MainActivity3.this, "table created ", Toast.LENGTH_LONG).show();
        String sql =
                "INSERT or replace INTO tbl_Contain (FNAME, longitude, latitude, info,notes) VALUES('nativity charch','31.704415','35.207163','it is an old charch where jesus was born','charch')" ;
        db.execSQL(sql);
        Toast.makeText(MainActivity3.this, "row1 exist ", Toast.LENGTH_LONG).show();
    }
    catch (Exception e) {
        Toast.makeText(MainActivity3.this, "ERROR "+e.toString(), Toast.LENGTH_LONG).show();
    }

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main_activity3, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

}

Aucun commentaire:

Enregistrer un commentaire