How to make a selection to the records that I created with my "high" method (to see that I save them as I want) my problem is that I want to create the table without a PK, and I also wanted to know what the form is more useful to upload the data saved in sqlite since the only way I know is to upload the records one by one and these I get from the TextView (Asyntask), summarizing my doubts - see sqlite records with a listview or the simplest (just check data) - upload to my identical tb in mysql with an asyntask the data saved in the sqlite (are several since I use a handler to insert as the location of the gps changes) // perhaps with an array or a cursor and traverse it?
and finally a tip to be able to make a good bd synchronization between the site and the web.
Android studio 2.2.1 api23
The application consists of the getlatitude () and getlongitude () methods of the GetLocation class for the gps and these are saved with an id + a date (4 fields) which, having an Internet connection, will be uploaded to my web server in the background. The data in the table (sqlite) will be deleted to prevent the database from growing too much when you finish uploading them with the asyntask.
import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
public class MyActivity extends Activity {
private TextView tv1, tv2, tv3, tv4;
private Cursor fila;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
tv1 = (TextView) findViewById(R.id.tv1);
tv2 = (TextView) findViewById(R.id.tv2);
tv3 = (TextView) findViewById(R.id.tv3);
tv4 = (TextView) findViewById(R.id.tv4);
}
public void Cargar (View v) {
//carga los datos ?¿
}
public void alta(View v) {
//crea objeto "admin" con el nombre con la BD "gpss" , pass "null", Version Bd "1"(update +1)
AdminSQLiteOpenHelper admin = new AdminSQLiteOpenHelper(this,"gpsss", null, 1);
//se crea un objeto de base de datos "db" que posee el objeto anterior con permisos de escrituras
SQLiteDatabase bd = admin.getWritableDatabase();
//extrae el texto de los editetext (4)
String id = tv1.getText().toString();
String latitud = tv2.getText().toString();
String longitud = tv3.getText().toString();
String fecha = tv4.getText().toString();
//inicializa "registro" (tipo array hashmap)
ContentValues registro = new ContentValues(); //es una clase para guardar datos para el intent
//pasa los parametros por via intent a la tabla gps
//tamhbine pasa el estr
registro.put("id", id);
registro.put("latitud", latitud);
registro.put("longitud", longitud);
registro.put("fecha", fecha);
bd.insert("gps", null, registro);
bd.close();
//pone en blanco los edittext (4)
//et1.setText("");
//et2.setText("");
//et3.setText("");
//et4.setText("");
Toast.makeText(this, "Se cargaron los datos de la persona",
Toast.LENGTH_SHORT).show();
}
public void SubirWeb(View V) {
//subir parametros cargados en textview
}
public void BorrarTabla (View v){
//delete TABLA y crear otra con el mismo nombre
}
}