Am new in android app development. I tried to find the solution of this problem but nothing was useful at last i am asking this question.
1) I am making profile in app but i want to show only name and email in that with the help of textviews. Data is inserted without error but i don't know how to get it and set on textview. Here is my code of database
public void User(String email,String name,SQLiteDatabase db){
ContentValues contentValues = new ContentValues();
contentValues.put(UserContract.NewUser.EMAIL,email);
contentValues.put(UserContract.NewUser.NAME,name);
db.insert(UserContract.NewUser.TABLE_NAME, null, contentValues);
Log.e("Database Operations", "User Added...");
}
public Cursor getMyProfile() {
SQLiteDatabase db = this.getReadableDatabase();
String query = "SELECT * FROM "+ UserContract.NewUser.TABLE_NAME;
Cursor cursor = db.rawQuery(query,null);
return cursor;
}
Using "User" data is inserted but I am getting error in "getMyProfile".Here is the profile code by which i want to set data to textview.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_profile);
MyName = (TextView)findViewById(R.id.MyName);
MyEmail = (TextView) findViewById(R.id.MyEmail);
Cursor cursor = userHelper.getMyProfile();
while (cursor.moveToFirst()){
MyName.setText(cursor.getString(0));
MyEmail.setText(cursor.getString(1));
}
2) Can anyone tell me how to save an image in database, Means i want to add profile picture but i do not know about that how to do that any suggestion.
Thanks in advance :)
Aucun commentaire:
Enregistrer un commentaire