Good afternoon I have 3 questions about a crud I made in my app.
1 I did a field search and it looks like it does not pick up any phone in the j7 line and I wanted to know if anyone can tell me why
2 Crud needs you to put something in Manifest or some kind of permission
3 How do I return a value that I put inside a table
I'll leave the crud of my app here
Create
public class Create {
public void createtable() {
SQLiteDatabase db = Maindb.getInstancia().getWritableDatabase();
String colunas = "(id INTEGER , valoragua INTEGER , acordar INTERGER ,
dormir INTERGER )";
String query = "CREATE TABLE IF NOT EXISTS " + Maindb.TABELA +
colunas;
db.execSQL(query);
}
}
Maindb
public class Maindb extends SQLiteOpenHelper{
public static final String DATABASE = "bdrespostas";
public static final int VERSION = 1;
public static final String TABELA = "respostasAguaCasa";
public static Maindb instancia;
public static Maindb getInstancia(){
if(instancia == null) instancia = new Maindb();
return instancia;
}
private Maindb( ){
super(Myapp.getContext() , DATABASE,null , VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
Myapp
private static Context context;
@Override
public void onCreate() {
context = getApplicationContext();
super.onCreate();
}
public static Context getContext() {
return context;
}
Read
public class Read {
public ArrayList<RespostasAguaCasa> getLista() {
SQLiteDatabase db =
Maindb.getInstancia().getWritableDatabase();
String query = "SELECT * FROM " + Maindb.TABELA;
ArrayList<RespostasAguaCasa> lista = new ArrayList<>();
Cursor c = db.rawQuery(query, null);
if (c.moveToFirst()) {
do {
RespostasAguaCasa resp = new RespostasAguaCasa(c.getString(0));
resp.setValoragua(c.getInt(1));
resp.setAcordar(c.getInt(2));
resp.setDormir(c.getInt(3));
lista.add(resp);
}
while (c.moveToNext());
{
}
}
c.close();
return lista;
}
}
Update
public class Create {
public void createtable() {
SQLiteDatabase db = Maindb.getInstancia().getWritableDatabase();
String colunas = "(id INTEGER , valoragua INTEGER , acordar
INTERGER , dormir INTERGER )";
String query = "CREATE TABLE IF NOT EXISTS " + Maindb.TABELA +
colunas;
db.execSQL(query);
}
}