Retrieving data from sqlite into a texxtview/edittext












-1














enter image description here



Its not compiling and i have no idea why... New to sqlite and tried to follow some question's answer on stack overflow but not able to figure it out. Modal class is MainDataHelper



Code



     MainDataHelper myDatabaseHelper = new MainDataHelper(getActivity());
myDatabaseHelper.openDataBase();

String text = myDatabaseHelper.getMostMessagesSent(); //this is the method to query

myDatabaseHelper.close();

mMostMessagesSent.setText(text);
mMostMessagesSent.setTextColor(Color.WHITE);


Helper



public class MainDataHelper extends Activity {
private int TotalMessagesSent;
private int TotalMessagesRecieved;
private int TotalMessages;
private String TotalTimeSpent;
private String MostMessagesSent;
private String MostMessagesRecieved;
private String MostTexted;
private String MostTimeSpent;
private int QuizTaken;
private int QuizTakers;
private int Reviewed;
private int Reviews;

public MainDataHelper() {
TotalMessagesSent = 0;
TotalMessagesRecieved = 0;
TotalMessages = 0;
TotalTimeSpent = "";
MostMessagesSent = "";
MostMessagesRecieved = "";
MostTexted = "";
MostTimeSpent = "";
QuizTaken = 0;
QuizTakers = 0;
Reviewed = 0;
Reviews = 0;
}
public MainDataHelper( int TotalMessagesSent, int TotalMessagesRecieved, int TotalMessages, String TotalTimeSpent,String MostMessagesSent, String MostMessagesRecieved, String MostTexted, String MostTimeSpent,int QuizTaken, int QuizTakers, int Reviewed, int Reviews) {
TotalMessagesSent = TotalMessagesSent;
TotalMessagesRecieved = TotalMessagesRecieved;
TotalMessages = TotalMessages;
TotalTimeSpent = TotalTimeSpent;
MostMessagesSent = MostMessagesSent;
MostMessagesRecieved = MostMessagesRecieved;
MostTexted = MostTexted;
MostTimeSpent = MostTimeSpent;
QuizTaken = QuizTaken;
QuizTakers = QuizTakers;
Reviewed = Reviewed;
Reviews = Reviews;
}

public int getTotalMessagesSent() {
return TotalMessagesSent;
}
public int getTotalMessagesRecieved() {
return TotalMessagesRecieved;
}
public int getTotalMessages() {
return TotalMessages;
}
public String getTotalTimeSpent() {
return TotalTimeSpent;
}
public String getMostMessagesSent() {
return MostMessagesSent;
}
public String getMostMessagesRecieved() {
return MostMessagesRecieved;
}
public String getMostTexted() {
return MostTexted;
}
public String getMostTimeSpent() {
return MostTimeSpent;
}
public int getQuizTaken() {
return QuizTaken;
}
public int getQuizTakers() {
return QuizTakers;
}
public int getReviewed() {
return Reviewed;
}
public int getReviews() {
return Reviews;
}


public void setTotalMessagesSent(int TotalMessagesSent) {
TotalMessagesSent = TotalMessagesSent;
}
public void setTotalMessagesRecieved(int TotalMessagesRecieved) {
TotalMessagesRecieved = TotalMessagesRecieved;
}
public void setTotalMessages(int TotalMessages) {
TotalMessages = TotalMessages;
}
public void setTotalTimeSpent(String TotalTimeSpent) { TotalTimeSpent = TotalTimeSpent; }
public void setMostMessagesSent(String MostMessagesSent) {
MostMessagesSent = MostMessagesSent;
}
public void setMostMessagesRecieved(String MostMessagesRecieved) {
MostMessagesRecieved = MostMessagesRecieved;
}
public void setMostTexted(String MostTexted) {
MostTexted = MostTexted;
}
public void setMostTimeSpent(String MostTimeSpent) { MostTimeSpent = MostTimeSpent; }
public void setQuizTaken(int QuizTaken) {
QuizTaken = QuizTaken;
}
public void setQuizTakers(int QuizTakers) {
QuizTakers = QuizTakers;
}
public void setReviewed(int Reviewed) { Reviewed = Reviewed; }

public void setReviews(int Reviews) {
Reviews = Reviews;
}


}



......................................................................................................................................................................................................................










share|improve this question




















  • 1




    Check the MainDataHelper class. It probably doesn't have a constructor that takes in an Activity/Context. And it also probably doesn't have the openDataBase() and close() methods.
    – Nebel22
    Nov 12 '18 at 18:09










  • Could you post your datahelper class?
    – Skemelio
    Nov 12 '18 at 18:09










  • look to the edited question @Skemelio
    – Akash R
    Nov 12 '18 at 18:13










  • That is an Activity that you've named MainDataHelper. Nothing to do with SQLite databases. The database helper should extend DatabaseHelper class. Read this guide -> developer.android.com/training/data-storage/…
    – Skemelio
    Nov 12 '18 at 18:21










  • In your picture, the getActivity() part is underline in red. Try passing in UsageSettings.this.
    – Ishaan Javali
    Nov 12 '18 at 18:37
















-1














enter image description here



Its not compiling and i have no idea why... New to sqlite and tried to follow some question's answer on stack overflow but not able to figure it out. Modal class is MainDataHelper



Code



     MainDataHelper myDatabaseHelper = new MainDataHelper(getActivity());
myDatabaseHelper.openDataBase();

String text = myDatabaseHelper.getMostMessagesSent(); //this is the method to query

myDatabaseHelper.close();

mMostMessagesSent.setText(text);
mMostMessagesSent.setTextColor(Color.WHITE);


Helper



public class MainDataHelper extends Activity {
private int TotalMessagesSent;
private int TotalMessagesRecieved;
private int TotalMessages;
private String TotalTimeSpent;
private String MostMessagesSent;
private String MostMessagesRecieved;
private String MostTexted;
private String MostTimeSpent;
private int QuizTaken;
private int QuizTakers;
private int Reviewed;
private int Reviews;

public MainDataHelper() {
TotalMessagesSent = 0;
TotalMessagesRecieved = 0;
TotalMessages = 0;
TotalTimeSpent = "";
MostMessagesSent = "";
MostMessagesRecieved = "";
MostTexted = "";
MostTimeSpent = "";
QuizTaken = 0;
QuizTakers = 0;
Reviewed = 0;
Reviews = 0;
}
public MainDataHelper( int TotalMessagesSent, int TotalMessagesRecieved, int TotalMessages, String TotalTimeSpent,String MostMessagesSent, String MostMessagesRecieved, String MostTexted, String MostTimeSpent,int QuizTaken, int QuizTakers, int Reviewed, int Reviews) {
TotalMessagesSent = TotalMessagesSent;
TotalMessagesRecieved = TotalMessagesRecieved;
TotalMessages = TotalMessages;
TotalTimeSpent = TotalTimeSpent;
MostMessagesSent = MostMessagesSent;
MostMessagesRecieved = MostMessagesRecieved;
MostTexted = MostTexted;
MostTimeSpent = MostTimeSpent;
QuizTaken = QuizTaken;
QuizTakers = QuizTakers;
Reviewed = Reviewed;
Reviews = Reviews;
}

public int getTotalMessagesSent() {
return TotalMessagesSent;
}
public int getTotalMessagesRecieved() {
return TotalMessagesRecieved;
}
public int getTotalMessages() {
return TotalMessages;
}
public String getTotalTimeSpent() {
return TotalTimeSpent;
}
public String getMostMessagesSent() {
return MostMessagesSent;
}
public String getMostMessagesRecieved() {
return MostMessagesRecieved;
}
public String getMostTexted() {
return MostTexted;
}
public String getMostTimeSpent() {
return MostTimeSpent;
}
public int getQuizTaken() {
return QuizTaken;
}
public int getQuizTakers() {
return QuizTakers;
}
public int getReviewed() {
return Reviewed;
}
public int getReviews() {
return Reviews;
}


public void setTotalMessagesSent(int TotalMessagesSent) {
TotalMessagesSent = TotalMessagesSent;
}
public void setTotalMessagesRecieved(int TotalMessagesRecieved) {
TotalMessagesRecieved = TotalMessagesRecieved;
}
public void setTotalMessages(int TotalMessages) {
TotalMessages = TotalMessages;
}
public void setTotalTimeSpent(String TotalTimeSpent) { TotalTimeSpent = TotalTimeSpent; }
public void setMostMessagesSent(String MostMessagesSent) {
MostMessagesSent = MostMessagesSent;
}
public void setMostMessagesRecieved(String MostMessagesRecieved) {
MostMessagesRecieved = MostMessagesRecieved;
}
public void setMostTexted(String MostTexted) {
MostTexted = MostTexted;
}
public void setMostTimeSpent(String MostTimeSpent) { MostTimeSpent = MostTimeSpent; }
public void setQuizTaken(int QuizTaken) {
QuizTaken = QuizTaken;
}
public void setQuizTakers(int QuizTakers) {
QuizTakers = QuizTakers;
}
public void setReviewed(int Reviewed) { Reviewed = Reviewed; }

public void setReviews(int Reviews) {
Reviews = Reviews;
}


}



......................................................................................................................................................................................................................










share|improve this question




















  • 1




    Check the MainDataHelper class. It probably doesn't have a constructor that takes in an Activity/Context. And it also probably doesn't have the openDataBase() and close() methods.
    – Nebel22
    Nov 12 '18 at 18:09










  • Could you post your datahelper class?
    – Skemelio
    Nov 12 '18 at 18:09










  • look to the edited question @Skemelio
    – Akash R
    Nov 12 '18 at 18:13










  • That is an Activity that you've named MainDataHelper. Nothing to do with SQLite databases. The database helper should extend DatabaseHelper class. Read this guide -> developer.android.com/training/data-storage/…
    – Skemelio
    Nov 12 '18 at 18:21










  • In your picture, the getActivity() part is underline in red. Try passing in UsageSettings.this.
    – Ishaan Javali
    Nov 12 '18 at 18:37














-1












-1








-1







enter image description here



Its not compiling and i have no idea why... New to sqlite and tried to follow some question's answer on stack overflow but not able to figure it out. Modal class is MainDataHelper



Code



     MainDataHelper myDatabaseHelper = new MainDataHelper(getActivity());
myDatabaseHelper.openDataBase();

String text = myDatabaseHelper.getMostMessagesSent(); //this is the method to query

myDatabaseHelper.close();

mMostMessagesSent.setText(text);
mMostMessagesSent.setTextColor(Color.WHITE);


Helper



public class MainDataHelper extends Activity {
private int TotalMessagesSent;
private int TotalMessagesRecieved;
private int TotalMessages;
private String TotalTimeSpent;
private String MostMessagesSent;
private String MostMessagesRecieved;
private String MostTexted;
private String MostTimeSpent;
private int QuizTaken;
private int QuizTakers;
private int Reviewed;
private int Reviews;

public MainDataHelper() {
TotalMessagesSent = 0;
TotalMessagesRecieved = 0;
TotalMessages = 0;
TotalTimeSpent = "";
MostMessagesSent = "";
MostMessagesRecieved = "";
MostTexted = "";
MostTimeSpent = "";
QuizTaken = 0;
QuizTakers = 0;
Reviewed = 0;
Reviews = 0;
}
public MainDataHelper( int TotalMessagesSent, int TotalMessagesRecieved, int TotalMessages, String TotalTimeSpent,String MostMessagesSent, String MostMessagesRecieved, String MostTexted, String MostTimeSpent,int QuizTaken, int QuizTakers, int Reviewed, int Reviews) {
TotalMessagesSent = TotalMessagesSent;
TotalMessagesRecieved = TotalMessagesRecieved;
TotalMessages = TotalMessages;
TotalTimeSpent = TotalTimeSpent;
MostMessagesSent = MostMessagesSent;
MostMessagesRecieved = MostMessagesRecieved;
MostTexted = MostTexted;
MostTimeSpent = MostTimeSpent;
QuizTaken = QuizTaken;
QuizTakers = QuizTakers;
Reviewed = Reviewed;
Reviews = Reviews;
}

public int getTotalMessagesSent() {
return TotalMessagesSent;
}
public int getTotalMessagesRecieved() {
return TotalMessagesRecieved;
}
public int getTotalMessages() {
return TotalMessages;
}
public String getTotalTimeSpent() {
return TotalTimeSpent;
}
public String getMostMessagesSent() {
return MostMessagesSent;
}
public String getMostMessagesRecieved() {
return MostMessagesRecieved;
}
public String getMostTexted() {
return MostTexted;
}
public String getMostTimeSpent() {
return MostTimeSpent;
}
public int getQuizTaken() {
return QuizTaken;
}
public int getQuizTakers() {
return QuizTakers;
}
public int getReviewed() {
return Reviewed;
}
public int getReviews() {
return Reviews;
}


public void setTotalMessagesSent(int TotalMessagesSent) {
TotalMessagesSent = TotalMessagesSent;
}
public void setTotalMessagesRecieved(int TotalMessagesRecieved) {
TotalMessagesRecieved = TotalMessagesRecieved;
}
public void setTotalMessages(int TotalMessages) {
TotalMessages = TotalMessages;
}
public void setTotalTimeSpent(String TotalTimeSpent) { TotalTimeSpent = TotalTimeSpent; }
public void setMostMessagesSent(String MostMessagesSent) {
MostMessagesSent = MostMessagesSent;
}
public void setMostMessagesRecieved(String MostMessagesRecieved) {
MostMessagesRecieved = MostMessagesRecieved;
}
public void setMostTexted(String MostTexted) {
MostTexted = MostTexted;
}
public void setMostTimeSpent(String MostTimeSpent) { MostTimeSpent = MostTimeSpent; }
public void setQuizTaken(int QuizTaken) {
QuizTaken = QuizTaken;
}
public void setQuizTakers(int QuizTakers) {
QuizTakers = QuizTakers;
}
public void setReviewed(int Reviewed) { Reviewed = Reviewed; }

public void setReviews(int Reviews) {
Reviews = Reviews;
}


}



......................................................................................................................................................................................................................










share|improve this question















enter image description here



Its not compiling and i have no idea why... New to sqlite and tried to follow some question's answer on stack overflow but not able to figure it out. Modal class is MainDataHelper



Code



     MainDataHelper myDatabaseHelper = new MainDataHelper(getActivity());
myDatabaseHelper.openDataBase();

String text = myDatabaseHelper.getMostMessagesSent(); //this is the method to query

myDatabaseHelper.close();

mMostMessagesSent.setText(text);
mMostMessagesSent.setTextColor(Color.WHITE);


Helper



public class MainDataHelper extends Activity {
private int TotalMessagesSent;
private int TotalMessagesRecieved;
private int TotalMessages;
private String TotalTimeSpent;
private String MostMessagesSent;
private String MostMessagesRecieved;
private String MostTexted;
private String MostTimeSpent;
private int QuizTaken;
private int QuizTakers;
private int Reviewed;
private int Reviews;

public MainDataHelper() {
TotalMessagesSent = 0;
TotalMessagesRecieved = 0;
TotalMessages = 0;
TotalTimeSpent = "";
MostMessagesSent = "";
MostMessagesRecieved = "";
MostTexted = "";
MostTimeSpent = "";
QuizTaken = 0;
QuizTakers = 0;
Reviewed = 0;
Reviews = 0;
}
public MainDataHelper( int TotalMessagesSent, int TotalMessagesRecieved, int TotalMessages, String TotalTimeSpent,String MostMessagesSent, String MostMessagesRecieved, String MostTexted, String MostTimeSpent,int QuizTaken, int QuizTakers, int Reviewed, int Reviews) {
TotalMessagesSent = TotalMessagesSent;
TotalMessagesRecieved = TotalMessagesRecieved;
TotalMessages = TotalMessages;
TotalTimeSpent = TotalTimeSpent;
MostMessagesSent = MostMessagesSent;
MostMessagesRecieved = MostMessagesRecieved;
MostTexted = MostTexted;
MostTimeSpent = MostTimeSpent;
QuizTaken = QuizTaken;
QuizTakers = QuizTakers;
Reviewed = Reviewed;
Reviews = Reviews;
}

public int getTotalMessagesSent() {
return TotalMessagesSent;
}
public int getTotalMessagesRecieved() {
return TotalMessagesRecieved;
}
public int getTotalMessages() {
return TotalMessages;
}
public String getTotalTimeSpent() {
return TotalTimeSpent;
}
public String getMostMessagesSent() {
return MostMessagesSent;
}
public String getMostMessagesRecieved() {
return MostMessagesRecieved;
}
public String getMostTexted() {
return MostTexted;
}
public String getMostTimeSpent() {
return MostTimeSpent;
}
public int getQuizTaken() {
return QuizTaken;
}
public int getQuizTakers() {
return QuizTakers;
}
public int getReviewed() {
return Reviewed;
}
public int getReviews() {
return Reviews;
}


public void setTotalMessagesSent(int TotalMessagesSent) {
TotalMessagesSent = TotalMessagesSent;
}
public void setTotalMessagesRecieved(int TotalMessagesRecieved) {
TotalMessagesRecieved = TotalMessagesRecieved;
}
public void setTotalMessages(int TotalMessages) {
TotalMessages = TotalMessages;
}
public void setTotalTimeSpent(String TotalTimeSpent) { TotalTimeSpent = TotalTimeSpent; }
public void setMostMessagesSent(String MostMessagesSent) {
MostMessagesSent = MostMessagesSent;
}
public void setMostMessagesRecieved(String MostMessagesRecieved) {
MostMessagesRecieved = MostMessagesRecieved;
}
public void setMostTexted(String MostTexted) {
MostTexted = MostTexted;
}
public void setMostTimeSpent(String MostTimeSpent) { MostTimeSpent = MostTimeSpent; }
public void setQuizTaken(int QuizTaken) {
QuizTaken = QuizTaken;
}
public void setQuizTakers(int QuizTakers) {
QuizTakers = QuizTakers;
}
public void setReviewed(int Reviewed) { Reviewed = Reviewed; }

public void setReviews(int Reviews) {
Reviews = Reviews;
}


}



......................................................................................................................................................................................................................







java android database sqlite android-studio






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 18:13

























asked Nov 12 '18 at 17:56









Akash R

1




1








  • 1




    Check the MainDataHelper class. It probably doesn't have a constructor that takes in an Activity/Context. And it also probably doesn't have the openDataBase() and close() methods.
    – Nebel22
    Nov 12 '18 at 18:09










  • Could you post your datahelper class?
    – Skemelio
    Nov 12 '18 at 18:09










  • look to the edited question @Skemelio
    – Akash R
    Nov 12 '18 at 18:13










  • That is an Activity that you've named MainDataHelper. Nothing to do with SQLite databases. The database helper should extend DatabaseHelper class. Read this guide -> developer.android.com/training/data-storage/…
    – Skemelio
    Nov 12 '18 at 18:21










  • In your picture, the getActivity() part is underline in red. Try passing in UsageSettings.this.
    – Ishaan Javali
    Nov 12 '18 at 18:37














  • 1




    Check the MainDataHelper class. It probably doesn't have a constructor that takes in an Activity/Context. And it also probably doesn't have the openDataBase() and close() methods.
    – Nebel22
    Nov 12 '18 at 18:09










  • Could you post your datahelper class?
    – Skemelio
    Nov 12 '18 at 18:09










  • look to the edited question @Skemelio
    – Akash R
    Nov 12 '18 at 18:13










  • That is an Activity that you've named MainDataHelper. Nothing to do with SQLite databases. The database helper should extend DatabaseHelper class. Read this guide -> developer.android.com/training/data-storage/…
    – Skemelio
    Nov 12 '18 at 18:21










  • In your picture, the getActivity() part is underline in red. Try passing in UsageSettings.this.
    – Ishaan Javali
    Nov 12 '18 at 18:37








1




1




Check the MainDataHelper class. It probably doesn't have a constructor that takes in an Activity/Context. And it also probably doesn't have the openDataBase() and close() methods.
– Nebel22
Nov 12 '18 at 18:09




Check the MainDataHelper class. It probably doesn't have a constructor that takes in an Activity/Context. And it also probably doesn't have the openDataBase() and close() methods.
– Nebel22
Nov 12 '18 at 18:09












Could you post your datahelper class?
– Skemelio
Nov 12 '18 at 18:09




Could you post your datahelper class?
– Skemelio
Nov 12 '18 at 18:09












look to the edited question @Skemelio
– Akash R
Nov 12 '18 at 18:13




look to the edited question @Skemelio
– Akash R
Nov 12 '18 at 18:13












That is an Activity that you've named MainDataHelper. Nothing to do with SQLite databases. The database helper should extend DatabaseHelper class. Read this guide -> developer.android.com/training/data-storage/…
– Skemelio
Nov 12 '18 at 18:21




That is an Activity that you've named MainDataHelper. Nothing to do with SQLite databases. The database helper should extend DatabaseHelper class. Read this guide -> developer.android.com/training/data-storage/…
– Skemelio
Nov 12 '18 at 18:21












In your picture, the getActivity() part is underline in red. Try passing in UsageSettings.this.
– Ishaan Javali
Nov 12 '18 at 18:37




In your picture, the getActivity() part is underline in red. Try passing in UsageSettings.this.
– Ishaan Javali
Nov 12 '18 at 18:37












1 Answer
1






active

oldest

votes


















1














It's not compiling due to a few reasons.




  1. First MainDataHelper does not have a constructor that accepts/takes an Activity. MainDataHelper has two constructors one takes no parameters, the other takes 12 parameters. You have to use one of the available constructors when instantiating a MainDataHelper object.


e.g. MainDataHelper myDatabaseHelper = new MainDataHelper(); would compile.




  1. There is no openDatabase method in MainDataHelper, you would either have to add such a method or do away with the line myDatabaseHelper.openDataBase();


  2. There is no close method in MainDataHelper, you would either have to add such a method or do away with the line myDatabaseHelper.close();



Considering that you want to use an SQLite database then you will use a sub-class of the SQLiteOpenHelper class that would be invoked from an Activity or a Fragment (or even many of these).



Before even considering writing a line of code you would need to understand you requirements for the database and have some sort of design (schema). Ignoring that and assuming (for demonstration) that you want a simple database with one table called questions and has one column called question then the following could be such a class (in this case MainDataBaseHelper.java) :-



public class MainDatabaseHelper extends SQLiteOpenHelper {

public static final String DATABASENAME = "question.db"; //<<<<<<<<<< name of the database
public static final int DATABASEVERSION = 1; //<<<<<<<<<< version number of the database
public static final String TABLE_QUESTION = "question"; //<<<<<<<<<< name of the quiz table
public static final String COLUMN_QUESTION_QUESTION = "question";

public MainDatabaseHelper(Context context) {
super(context, DATABASENAME, null, DATABASEVERSION);
}

//<<<<<<<<<< Called ONCE when the database is first created (first time an attempt is made to open if)
@Override
public void onCreate(SQLiteDatabase db) {
String crt_questiontable_sql = "CREATE TABLE IF NOT EXISTS " + TABLE_QUESTION + "(" +
COLUMN_QUESTION_QUESTION + " TEXT" +
")";
db.execSQL(crt_questiontable_sql);
}

@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

}

public long addQuestion(String question) {
ContentValues cv = new ContentValues();
cv.put(COLUMN_QUESTION_QUESTION,question);
return this.getWritableDatabase().insert(TABLE_QUESTION,null,cv);
}

public Cursor getAllQuestions() {
return this.getWritableDatabase().query(TABLE_QUESTION,null,null,null,null,null,null);
}
}


With the above class existing your code could then be (as a simple example) :-



    MainDatabaseHelper myDBHlpr = new MainDatabaseHelper(getActivity()); // Instantiate a MainDatabasehelper object called myDBHlpr

// Add some questions to the questions table
myDBHlpr.addQuestion("This is the first question");
myDBHlpr.addQuestion("This is another question");
myDBHlpr.addQuestion("Yet another question");

// Now get all of the questions
Cursor csr = myDBHlpr.getAllQuestions();

Log.d("DBINFO","There are " + String.valueOf(csr.getCount()) + " questions in the database.");
// Loop through all the questions
while (csr.moveToNext()) {
Log.d("DBINFO",
"Question " +
String.valueOf(csr.getPosition() + 1) +
" is " + csr.getString(csr.getColumnIndex(MainDatabaseHelper.COLUMN_QUESTION_QUESTION))
);
mMostMessagesSent.setText(csr.getString(csr.getColumnIndex(MainDatabaseHelper.COLUMN_QUESTION_QUESTION));
}
csr.close(); //<<<<<<<<<< Should always close Cursor when done with it.

//mMostMessagesSent.setText(text); //<<<<<<<<<< done in the loop through the cursor (for demonstration very likely only the last question will be seen)
mMostMessagesSent.setTextColor(Color.WHITE);


When run (for the first time) the log would then include :-




11-12 20:17:16.345 1376-1376/? D/DBINFO: There are 3 questions in the database.
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 1 is This is the first question
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 2 is This is another question
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 3 is Yet another question



Additionally the last question (which may or may not be the last question added) will be displayed in the TextView.




  • Note 3 rows would be added to the table each time the above is run.

  • Note this is purely intended as an introduction/demonstration there is a great deal more that needs to be done, such as designing the database.






share|improve this answer





















  • public static Cursor getAllQuestions(FragmentActivity activity) { return this.getWritableDatabase().query(TABLE_NAME,null,null,null,null,null,null); }
    – Akash R
    Nov 12 '18 at 21:24










  • I copied your getAllQuestions method but in the activity Cursor csr = MainData.getAllQuestions(); This lina it asked me to make it statis saying it cannot be referenced from a statis context
    – Akash R
    Nov 12 '18 at 21:26










  • but if i change it to static i get error line under this.getWrttableDatabase() saying it shouldnt be static
    – Akash R
    Nov 12 '18 at 21:26












  • Can u help me solve this please
    – Akash R
    Nov 12 '18 at 21:27










  • You CANNOT just copy that method. You NEED a new class that is a subclass of SQLIteOpenHelper.
    – MikeT
    Nov 12 '18 at 21:27











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267615%2fretrieving-data-from-sqlite-into-a-texxtview-edittext%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














It's not compiling due to a few reasons.




  1. First MainDataHelper does not have a constructor that accepts/takes an Activity. MainDataHelper has two constructors one takes no parameters, the other takes 12 parameters. You have to use one of the available constructors when instantiating a MainDataHelper object.


e.g. MainDataHelper myDatabaseHelper = new MainDataHelper(); would compile.




  1. There is no openDatabase method in MainDataHelper, you would either have to add such a method or do away with the line myDatabaseHelper.openDataBase();


  2. There is no close method in MainDataHelper, you would either have to add such a method or do away with the line myDatabaseHelper.close();



Considering that you want to use an SQLite database then you will use a sub-class of the SQLiteOpenHelper class that would be invoked from an Activity or a Fragment (or even many of these).



Before even considering writing a line of code you would need to understand you requirements for the database and have some sort of design (schema). Ignoring that and assuming (for demonstration) that you want a simple database with one table called questions and has one column called question then the following could be such a class (in this case MainDataBaseHelper.java) :-



public class MainDatabaseHelper extends SQLiteOpenHelper {

public static final String DATABASENAME = "question.db"; //<<<<<<<<<< name of the database
public static final int DATABASEVERSION = 1; //<<<<<<<<<< version number of the database
public static final String TABLE_QUESTION = "question"; //<<<<<<<<<< name of the quiz table
public static final String COLUMN_QUESTION_QUESTION = "question";

public MainDatabaseHelper(Context context) {
super(context, DATABASENAME, null, DATABASEVERSION);
}

//<<<<<<<<<< Called ONCE when the database is first created (first time an attempt is made to open if)
@Override
public void onCreate(SQLiteDatabase db) {
String crt_questiontable_sql = "CREATE TABLE IF NOT EXISTS " + TABLE_QUESTION + "(" +
COLUMN_QUESTION_QUESTION + " TEXT" +
")";
db.execSQL(crt_questiontable_sql);
}

@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

}

public long addQuestion(String question) {
ContentValues cv = new ContentValues();
cv.put(COLUMN_QUESTION_QUESTION,question);
return this.getWritableDatabase().insert(TABLE_QUESTION,null,cv);
}

public Cursor getAllQuestions() {
return this.getWritableDatabase().query(TABLE_QUESTION,null,null,null,null,null,null);
}
}


With the above class existing your code could then be (as a simple example) :-



    MainDatabaseHelper myDBHlpr = new MainDatabaseHelper(getActivity()); // Instantiate a MainDatabasehelper object called myDBHlpr

// Add some questions to the questions table
myDBHlpr.addQuestion("This is the first question");
myDBHlpr.addQuestion("This is another question");
myDBHlpr.addQuestion("Yet another question");

// Now get all of the questions
Cursor csr = myDBHlpr.getAllQuestions();

Log.d("DBINFO","There are " + String.valueOf(csr.getCount()) + " questions in the database.");
// Loop through all the questions
while (csr.moveToNext()) {
Log.d("DBINFO",
"Question " +
String.valueOf(csr.getPosition() + 1) +
" is " + csr.getString(csr.getColumnIndex(MainDatabaseHelper.COLUMN_QUESTION_QUESTION))
);
mMostMessagesSent.setText(csr.getString(csr.getColumnIndex(MainDatabaseHelper.COLUMN_QUESTION_QUESTION));
}
csr.close(); //<<<<<<<<<< Should always close Cursor when done with it.

//mMostMessagesSent.setText(text); //<<<<<<<<<< done in the loop through the cursor (for demonstration very likely only the last question will be seen)
mMostMessagesSent.setTextColor(Color.WHITE);


When run (for the first time) the log would then include :-




11-12 20:17:16.345 1376-1376/? D/DBINFO: There are 3 questions in the database.
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 1 is This is the first question
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 2 is This is another question
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 3 is Yet another question



Additionally the last question (which may or may not be the last question added) will be displayed in the TextView.




  • Note 3 rows would be added to the table each time the above is run.

  • Note this is purely intended as an introduction/demonstration there is a great deal more that needs to be done, such as designing the database.






share|improve this answer





















  • public static Cursor getAllQuestions(FragmentActivity activity) { return this.getWritableDatabase().query(TABLE_NAME,null,null,null,null,null,null); }
    – Akash R
    Nov 12 '18 at 21:24










  • I copied your getAllQuestions method but in the activity Cursor csr = MainData.getAllQuestions(); This lina it asked me to make it statis saying it cannot be referenced from a statis context
    – Akash R
    Nov 12 '18 at 21:26










  • but if i change it to static i get error line under this.getWrttableDatabase() saying it shouldnt be static
    – Akash R
    Nov 12 '18 at 21:26












  • Can u help me solve this please
    – Akash R
    Nov 12 '18 at 21:27










  • You CANNOT just copy that method. You NEED a new class that is a subclass of SQLIteOpenHelper.
    – MikeT
    Nov 12 '18 at 21:27
















1














It's not compiling due to a few reasons.




  1. First MainDataHelper does not have a constructor that accepts/takes an Activity. MainDataHelper has two constructors one takes no parameters, the other takes 12 parameters. You have to use one of the available constructors when instantiating a MainDataHelper object.


e.g. MainDataHelper myDatabaseHelper = new MainDataHelper(); would compile.




  1. There is no openDatabase method in MainDataHelper, you would either have to add such a method or do away with the line myDatabaseHelper.openDataBase();


  2. There is no close method in MainDataHelper, you would either have to add such a method or do away with the line myDatabaseHelper.close();



Considering that you want to use an SQLite database then you will use a sub-class of the SQLiteOpenHelper class that would be invoked from an Activity or a Fragment (or even many of these).



Before even considering writing a line of code you would need to understand you requirements for the database and have some sort of design (schema). Ignoring that and assuming (for demonstration) that you want a simple database with one table called questions and has one column called question then the following could be such a class (in this case MainDataBaseHelper.java) :-



public class MainDatabaseHelper extends SQLiteOpenHelper {

public static final String DATABASENAME = "question.db"; //<<<<<<<<<< name of the database
public static final int DATABASEVERSION = 1; //<<<<<<<<<< version number of the database
public static final String TABLE_QUESTION = "question"; //<<<<<<<<<< name of the quiz table
public static final String COLUMN_QUESTION_QUESTION = "question";

public MainDatabaseHelper(Context context) {
super(context, DATABASENAME, null, DATABASEVERSION);
}

//<<<<<<<<<< Called ONCE when the database is first created (first time an attempt is made to open if)
@Override
public void onCreate(SQLiteDatabase db) {
String crt_questiontable_sql = "CREATE TABLE IF NOT EXISTS " + TABLE_QUESTION + "(" +
COLUMN_QUESTION_QUESTION + " TEXT" +
")";
db.execSQL(crt_questiontable_sql);
}

@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

}

public long addQuestion(String question) {
ContentValues cv = new ContentValues();
cv.put(COLUMN_QUESTION_QUESTION,question);
return this.getWritableDatabase().insert(TABLE_QUESTION,null,cv);
}

public Cursor getAllQuestions() {
return this.getWritableDatabase().query(TABLE_QUESTION,null,null,null,null,null,null);
}
}


With the above class existing your code could then be (as a simple example) :-



    MainDatabaseHelper myDBHlpr = new MainDatabaseHelper(getActivity()); // Instantiate a MainDatabasehelper object called myDBHlpr

// Add some questions to the questions table
myDBHlpr.addQuestion("This is the first question");
myDBHlpr.addQuestion("This is another question");
myDBHlpr.addQuestion("Yet another question");

// Now get all of the questions
Cursor csr = myDBHlpr.getAllQuestions();

Log.d("DBINFO","There are " + String.valueOf(csr.getCount()) + " questions in the database.");
// Loop through all the questions
while (csr.moveToNext()) {
Log.d("DBINFO",
"Question " +
String.valueOf(csr.getPosition() + 1) +
" is " + csr.getString(csr.getColumnIndex(MainDatabaseHelper.COLUMN_QUESTION_QUESTION))
);
mMostMessagesSent.setText(csr.getString(csr.getColumnIndex(MainDatabaseHelper.COLUMN_QUESTION_QUESTION));
}
csr.close(); //<<<<<<<<<< Should always close Cursor when done with it.

//mMostMessagesSent.setText(text); //<<<<<<<<<< done in the loop through the cursor (for demonstration very likely only the last question will be seen)
mMostMessagesSent.setTextColor(Color.WHITE);


When run (for the first time) the log would then include :-




11-12 20:17:16.345 1376-1376/? D/DBINFO: There are 3 questions in the database.
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 1 is This is the first question
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 2 is This is another question
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 3 is Yet another question



Additionally the last question (which may or may not be the last question added) will be displayed in the TextView.




  • Note 3 rows would be added to the table each time the above is run.

  • Note this is purely intended as an introduction/demonstration there is a great deal more that needs to be done, such as designing the database.






share|improve this answer





















  • public static Cursor getAllQuestions(FragmentActivity activity) { return this.getWritableDatabase().query(TABLE_NAME,null,null,null,null,null,null); }
    – Akash R
    Nov 12 '18 at 21:24










  • I copied your getAllQuestions method but in the activity Cursor csr = MainData.getAllQuestions(); This lina it asked me to make it statis saying it cannot be referenced from a statis context
    – Akash R
    Nov 12 '18 at 21:26










  • but if i change it to static i get error line under this.getWrttableDatabase() saying it shouldnt be static
    – Akash R
    Nov 12 '18 at 21:26












  • Can u help me solve this please
    – Akash R
    Nov 12 '18 at 21:27










  • You CANNOT just copy that method. You NEED a new class that is a subclass of SQLIteOpenHelper.
    – MikeT
    Nov 12 '18 at 21:27














1












1








1






It's not compiling due to a few reasons.




  1. First MainDataHelper does not have a constructor that accepts/takes an Activity. MainDataHelper has two constructors one takes no parameters, the other takes 12 parameters. You have to use one of the available constructors when instantiating a MainDataHelper object.


e.g. MainDataHelper myDatabaseHelper = new MainDataHelper(); would compile.




  1. There is no openDatabase method in MainDataHelper, you would either have to add such a method or do away with the line myDatabaseHelper.openDataBase();


  2. There is no close method in MainDataHelper, you would either have to add such a method or do away with the line myDatabaseHelper.close();



Considering that you want to use an SQLite database then you will use a sub-class of the SQLiteOpenHelper class that would be invoked from an Activity or a Fragment (or even many of these).



Before even considering writing a line of code you would need to understand you requirements for the database and have some sort of design (schema). Ignoring that and assuming (for demonstration) that you want a simple database with one table called questions and has one column called question then the following could be such a class (in this case MainDataBaseHelper.java) :-



public class MainDatabaseHelper extends SQLiteOpenHelper {

public static final String DATABASENAME = "question.db"; //<<<<<<<<<< name of the database
public static final int DATABASEVERSION = 1; //<<<<<<<<<< version number of the database
public static final String TABLE_QUESTION = "question"; //<<<<<<<<<< name of the quiz table
public static final String COLUMN_QUESTION_QUESTION = "question";

public MainDatabaseHelper(Context context) {
super(context, DATABASENAME, null, DATABASEVERSION);
}

//<<<<<<<<<< Called ONCE when the database is first created (first time an attempt is made to open if)
@Override
public void onCreate(SQLiteDatabase db) {
String crt_questiontable_sql = "CREATE TABLE IF NOT EXISTS " + TABLE_QUESTION + "(" +
COLUMN_QUESTION_QUESTION + " TEXT" +
")";
db.execSQL(crt_questiontable_sql);
}

@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

}

public long addQuestion(String question) {
ContentValues cv = new ContentValues();
cv.put(COLUMN_QUESTION_QUESTION,question);
return this.getWritableDatabase().insert(TABLE_QUESTION,null,cv);
}

public Cursor getAllQuestions() {
return this.getWritableDatabase().query(TABLE_QUESTION,null,null,null,null,null,null);
}
}


With the above class existing your code could then be (as a simple example) :-



    MainDatabaseHelper myDBHlpr = new MainDatabaseHelper(getActivity()); // Instantiate a MainDatabasehelper object called myDBHlpr

// Add some questions to the questions table
myDBHlpr.addQuestion("This is the first question");
myDBHlpr.addQuestion("This is another question");
myDBHlpr.addQuestion("Yet another question");

// Now get all of the questions
Cursor csr = myDBHlpr.getAllQuestions();

Log.d("DBINFO","There are " + String.valueOf(csr.getCount()) + " questions in the database.");
// Loop through all the questions
while (csr.moveToNext()) {
Log.d("DBINFO",
"Question " +
String.valueOf(csr.getPosition() + 1) +
" is " + csr.getString(csr.getColumnIndex(MainDatabaseHelper.COLUMN_QUESTION_QUESTION))
);
mMostMessagesSent.setText(csr.getString(csr.getColumnIndex(MainDatabaseHelper.COLUMN_QUESTION_QUESTION));
}
csr.close(); //<<<<<<<<<< Should always close Cursor when done with it.

//mMostMessagesSent.setText(text); //<<<<<<<<<< done in the loop through the cursor (for demonstration very likely only the last question will be seen)
mMostMessagesSent.setTextColor(Color.WHITE);


When run (for the first time) the log would then include :-




11-12 20:17:16.345 1376-1376/? D/DBINFO: There are 3 questions in the database.
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 1 is This is the first question
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 2 is This is another question
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 3 is Yet another question



Additionally the last question (which may or may not be the last question added) will be displayed in the TextView.




  • Note 3 rows would be added to the table each time the above is run.

  • Note this is purely intended as an introduction/demonstration there is a great deal more that needs to be done, such as designing the database.






share|improve this answer












It's not compiling due to a few reasons.




  1. First MainDataHelper does not have a constructor that accepts/takes an Activity. MainDataHelper has two constructors one takes no parameters, the other takes 12 parameters. You have to use one of the available constructors when instantiating a MainDataHelper object.


e.g. MainDataHelper myDatabaseHelper = new MainDataHelper(); would compile.




  1. There is no openDatabase method in MainDataHelper, you would either have to add such a method or do away with the line myDatabaseHelper.openDataBase();


  2. There is no close method in MainDataHelper, you would either have to add such a method or do away with the line myDatabaseHelper.close();



Considering that you want to use an SQLite database then you will use a sub-class of the SQLiteOpenHelper class that would be invoked from an Activity or a Fragment (or even many of these).



Before even considering writing a line of code you would need to understand you requirements for the database and have some sort of design (schema). Ignoring that and assuming (for demonstration) that you want a simple database with one table called questions and has one column called question then the following could be such a class (in this case MainDataBaseHelper.java) :-



public class MainDatabaseHelper extends SQLiteOpenHelper {

public static final String DATABASENAME = "question.db"; //<<<<<<<<<< name of the database
public static final int DATABASEVERSION = 1; //<<<<<<<<<< version number of the database
public static final String TABLE_QUESTION = "question"; //<<<<<<<<<< name of the quiz table
public static final String COLUMN_QUESTION_QUESTION = "question";

public MainDatabaseHelper(Context context) {
super(context, DATABASENAME, null, DATABASEVERSION);
}

//<<<<<<<<<< Called ONCE when the database is first created (first time an attempt is made to open if)
@Override
public void onCreate(SQLiteDatabase db) {
String crt_questiontable_sql = "CREATE TABLE IF NOT EXISTS " + TABLE_QUESTION + "(" +
COLUMN_QUESTION_QUESTION + " TEXT" +
")";
db.execSQL(crt_questiontable_sql);
}

@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

}

public long addQuestion(String question) {
ContentValues cv = new ContentValues();
cv.put(COLUMN_QUESTION_QUESTION,question);
return this.getWritableDatabase().insert(TABLE_QUESTION,null,cv);
}

public Cursor getAllQuestions() {
return this.getWritableDatabase().query(TABLE_QUESTION,null,null,null,null,null,null);
}
}


With the above class existing your code could then be (as a simple example) :-



    MainDatabaseHelper myDBHlpr = new MainDatabaseHelper(getActivity()); // Instantiate a MainDatabasehelper object called myDBHlpr

// Add some questions to the questions table
myDBHlpr.addQuestion("This is the first question");
myDBHlpr.addQuestion("This is another question");
myDBHlpr.addQuestion("Yet another question");

// Now get all of the questions
Cursor csr = myDBHlpr.getAllQuestions();

Log.d("DBINFO","There are " + String.valueOf(csr.getCount()) + " questions in the database.");
// Loop through all the questions
while (csr.moveToNext()) {
Log.d("DBINFO",
"Question " +
String.valueOf(csr.getPosition() + 1) +
" is " + csr.getString(csr.getColumnIndex(MainDatabaseHelper.COLUMN_QUESTION_QUESTION))
);
mMostMessagesSent.setText(csr.getString(csr.getColumnIndex(MainDatabaseHelper.COLUMN_QUESTION_QUESTION));
}
csr.close(); //<<<<<<<<<< Should always close Cursor when done with it.

//mMostMessagesSent.setText(text); //<<<<<<<<<< done in the loop through the cursor (for demonstration very likely only the last question will be seen)
mMostMessagesSent.setTextColor(Color.WHITE);


When run (for the first time) the log would then include :-




11-12 20:17:16.345 1376-1376/? D/DBINFO: There are 3 questions in the database.
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 1 is This is the first question
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 2 is This is another question
11-12 20:17:16.345 1376-1376/? D/DBINFO: Question 3 is Yet another question



Additionally the last question (which may or may not be the last question added) will be displayed in the TextView.




  • Note 3 rows would be added to the table each time the above is run.

  • Note this is purely intended as an introduction/demonstration there is a great deal more that needs to be done, such as designing the database.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 '18 at 20:32









MikeT

15.1k112441




15.1k112441












  • public static Cursor getAllQuestions(FragmentActivity activity) { return this.getWritableDatabase().query(TABLE_NAME,null,null,null,null,null,null); }
    – Akash R
    Nov 12 '18 at 21:24










  • I copied your getAllQuestions method but in the activity Cursor csr = MainData.getAllQuestions(); This lina it asked me to make it statis saying it cannot be referenced from a statis context
    – Akash R
    Nov 12 '18 at 21:26










  • but if i change it to static i get error line under this.getWrttableDatabase() saying it shouldnt be static
    – Akash R
    Nov 12 '18 at 21:26












  • Can u help me solve this please
    – Akash R
    Nov 12 '18 at 21:27










  • You CANNOT just copy that method. You NEED a new class that is a subclass of SQLIteOpenHelper.
    – MikeT
    Nov 12 '18 at 21:27


















  • public static Cursor getAllQuestions(FragmentActivity activity) { return this.getWritableDatabase().query(TABLE_NAME,null,null,null,null,null,null); }
    – Akash R
    Nov 12 '18 at 21:24










  • I copied your getAllQuestions method but in the activity Cursor csr = MainData.getAllQuestions(); This lina it asked me to make it statis saying it cannot be referenced from a statis context
    – Akash R
    Nov 12 '18 at 21:26










  • but if i change it to static i get error line under this.getWrttableDatabase() saying it shouldnt be static
    – Akash R
    Nov 12 '18 at 21:26












  • Can u help me solve this please
    – Akash R
    Nov 12 '18 at 21:27










  • You CANNOT just copy that method. You NEED a new class that is a subclass of SQLIteOpenHelper.
    – MikeT
    Nov 12 '18 at 21:27
















public static Cursor getAllQuestions(FragmentActivity activity) { return this.getWritableDatabase().query(TABLE_NAME,null,null,null,null,null,null); }
– Akash R
Nov 12 '18 at 21:24




public static Cursor getAllQuestions(FragmentActivity activity) { return this.getWritableDatabase().query(TABLE_NAME,null,null,null,null,null,null); }
– Akash R
Nov 12 '18 at 21:24












I copied your getAllQuestions method but in the activity Cursor csr = MainData.getAllQuestions(); This lina it asked me to make it statis saying it cannot be referenced from a statis context
– Akash R
Nov 12 '18 at 21:26




I copied your getAllQuestions method but in the activity Cursor csr = MainData.getAllQuestions(); This lina it asked me to make it statis saying it cannot be referenced from a statis context
– Akash R
Nov 12 '18 at 21:26












but if i change it to static i get error line under this.getWrttableDatabase() saying it shouldnt be static
– Akash R
Nov 12 '18 at 21:26






but if i change it to static i get error line under this.getWrttableDatabase() saying it shouldnt be static
– Akash R
Nov 12 '18 at 21:26














Can u help me solve this please
– Akash R
Nov 12 '18 at 21:27




Can u help me solve this please
– Akash R
Nov 12 '18 at 21:27












You CANNOT just copy that method. You NEED a new class that is a subclass of SQLIteOpenHelper.
– MikeT
Nov 12 '18 at 21:27




You CANNOT just copy that method. You NEED a new class that is a subclass of SQLIteOpenHelper.
– MikeT
Nov 12 '18 at 21:27


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267615%2fretrieving-data-from-sqlite-into-a-texxtview-edittext%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

The Sandy Post

Danny Elfman

Pages that link to "Head v. Amoskeag Manufacturing Co."