Remove All Ads from XDA

WebApp + sql. Can't make sql to work.

3 posts
Thanks Meter: 0
By rodrigojpf, Junior Member on 27th August 2019, 07:32 PM
Post Reply Email Thread
Hey guys.
So, I've spent the last two days watching every tutorial about working with sqlite, but I'm doing something wrong and can't find out what.
The app is done, only needs the SQLite part, Its basicly a webapp with favorites.
Altough I have changed the code several times, this is what I ended up with:
package com.rjpf.mywebapps;

import android.content.ContentValues;
import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;

public class DBManager
private DbHelper dbHelper;
private Context context;
private SQLiteDatabase database;
public DBManager(Context c)
public DBManager open() throws SQLException
dbHelper = new DbHelper(context);
database = dbHelper.getWritableDatabase();
return this;
public void close()
public void insert(String name, String url)
ContentValues contentValue = new ContentValues();
contentValue.put(DbHelper.CONTACTS_COLUMN_NAME, name);
contentValue.put(DbHelper.CONTACTS_COLUMN_URL, url);
database.insert(dbHelper.CONTACTS_TABLE_NAME, null, contentValue);

When I try to call it in the main activity with:
private LinearLayout Layout_Add;
private TextView TxT_add_nomE;
private TextView TxT_add_urL;
private Button Button_Add_to_DB;
private Button btn_BACK_Add;
DbHelper myDB;
protected void onCreate(Bundle savedInstanceState) {
myDB = new DbHelper(this);
Button_Add_to_DB.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {



public void Add_ItemToDb()
if (TxT_add_nomE.getText().toString().trim().length() == 0 || TxT_add_urL.getText().toString().trim().length() == 0)
TxT_add_nomE.setText("Please don't leave fields empty!");
String addNome = TxT_add_nomE.getText().toString();
String addUrl = TxT_add_urL.getText().toString();

DBManager DataManager = new DBManager(this);
DataManager.insert(addNome,addUrl); // This line is what gives the error, when I click the button to add the App craches


Thanks in advance and sorry for the long post, This is my first app and also the first time in java
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes