passing data from sqlite to a textview The Next CEO of Stack OverflowIs Java “pass-by-reference” or “pass-by-value”?Create ArrayList from arrayHow do I center text horizontally and vertically in a TextView?How do I pass a variable by reference?Stop EditText from gaining focus at Activity startupImprove INSERT-per-second performance of SQLite?Making TextView scrollable on AndroidAndroid database recreates every time application is launchedAuto Scale TextView Text to Fit within BoundsCursor for database on sdcard not closing or deactive
Why is information "lost" when it got into a black hole?
Writing differences on a blackboard
Poetry, calligrams and TikZ/PStricks challenge
Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?
What happened in Rome, when the western empire "fell"?
Why don't programming languages automatically manage the synchronous/asynchronous problem?
Why does the flight controls check come before arming the autobrake on the A320?
Why, when going from special to general relativity, do we just replace partial derivatives with covariant derivatives?
Legal workarounds for testamentary trust perceived as unfair
Calculator final project in Python
Make solar eclipses exceedingly rare, but still have new moons
Which one is the true statement?
Can MTA send mail via a relay without being told so?
What is meant by "large scale tonal organization?"
Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?
Does Germany produce more waste than the US?
Why do remote US companies require working in the US?
Why isn't the Mueller report being released completely and unredacted?
Are police here, aren't itthey?
Is French Guiana a (hard) EU border?
Is the D&D universe the same as the Forgotten Realms universe?
A small doubt about the dominated convergence theorem
Dominated convergence theorem - what sequence?
Is wanting to ask what to write an indication that you need to change your story?
passing data from sqlite to a textview
The Next CEO of Stack OverflowIs Java “pass-by-reference” or “pass-by-value”?Create ArrayList from arrayHow do I center text horizontally and vertically in a TextView?How do I pass a variable by reference?Stop EditText from gaining focus at Activity startupImprove INSERT-per-second performance of SQLite?Making TextView scrollable on AndroidAndroid database recreates every time application is launchedAuto Scale TextView Text to Fit within BoundsCursor for database on sdcard not closing or deactive
I am trying to pass data from an sqlite table to a username textview in my home fragment class, I am having difficulties displaying the data in the textview.
Here is my DatabaseHelper class where all my table is created:
public class DatabaseHandler extends SQLiteOpenHelper {
// All Static variables
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "u168512214_barzd";
// Login table name
private static final String TABLE_LOGIN = "login";
// Login Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_NAME = "name";
private static final String KEY_EMAIL = "email";
private static final String KEY_UID = "uid";
private static final String KEY_CREATED_AT = "created_at";
public DatabaseHandler(Context context)
super(context, DATABASE_NAME, null, DATABASE_VERSION);
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db)
String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_LOGIN + "("
+ KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_NAME + " TEXT,"
+ KEY_EMAIL + " TEXT UNIQUE,"
+ KEY_UID + " TEXT,"
+ KEY_CREATED_AT + " TEXT" + ")";
db.execSQL(CREATE_LOGIN_TABLE);
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOGIN);
// Create tables again
onCreate(db);
/**
* Storing user details in database
* */
public void addUser(String name, String email, String uid, String created_at)
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_NAME, name); // Name
values.put(KEY_EMAIL, email); // Email
values.put(KEY_UID, uid); // Email
values.put(KEY_CREATED_AT, created_at); // Created At
// Inserting Row
db.insert(TABLE_LOGIN, null, values);
db.close(); // Closing database connection
/**
* Getting user data from database
* */
public HashMap<String, String> getUserDetails()
HashMap<String,String> user = new HashMap<String,String>();
String selectQuery = "SELECT * FROM " + TABLE_LOGIN;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// Move to first row
cursor.moveToFirst();
if(cursor.getCount() > 0)
Log.i("key_name","value is: " + cursor.getString(1));
Log.i("key_email","value is: " + cursor.getString(2));
Log.i("key_uid","value is: " + cursor.getString(3));
Log.i("key_created_at","value is: " + cursor.getString(4));
cursor.close();
db.close();
// return user
return user;
/**
* Getting user login status
* return true if rows are there in table
* */
public int getRowCount()
String countQuery = "SELECT * FROM " + TABLE_LOGIN;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
int rowCount = cursor.getCount();
db.close();
cursor.close();
// return row count
return rowCount;
her is my fragmentHome class where I want to display the username in a textView:
DatabaseHandler db;
AlertDialogManager alert = new AlertDialogManager();
// Session Manager Class
ArrayList> nameList;
public HomeFragment()
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_home, container, false);
btnViewBars = (Button)rootView.findViewById(R.id.btnViewBars);
btnNewBar = (Button)rootView.findViewById(R.id.btnCreateBar);
// return rootView;
db= new DatabaseHandler(getActivity());
HashMap<String, String> user = db.getUserDetails();
for(int i=0; i<user.size();i++)
username.settext(user.get(i).get("name"));
java android sqlite textview parameter-passing
|
show 1 more comment
I am trying to pass data from an sqlite table to a username textview in my home fragment class, I am having difficulties displaying the data in the textview.
Here is my DatabaseHelper class where all my table is created:
public class DatabaseHandler extends SQLiteOpenHelper {
// All Static variables
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "u168512214_barzd";
// Login table name
private static final String TABLE_LOGIN = "login";
// Login Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_NAME = "name";
private static final String KEY_EMAIL = "email";
private static final String KEY_UID = "uid";
private static final String KEY_CREATED_AT = "created_at";
public DatabaseHandler(Context context)
super(context, DATABASE_NAME, null, DATABASE_VERSION);
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db)
String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_LOGIN + "("
+ KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_NAME + " TEXT,"
+ KEY_EMAIL + " TEXT UNIQUE,"
+ KEY_UID + " TEXT,"
+ KEY_CREATED_AT + " TEXT" + ")";
db.execSQL(CREATE_LOGIN_TABLE);
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOGIN);
// Create tables again
onCreate(db);
/**
* Storing user details in database
* */
public void addUser(String name, String email, String uid, String created_at)
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_NAME, name); // Name
values.put(KEY_EMAIL, email); // Email
values.put(KEY_UID, uid); // Email
values.put(KEY_CREATED_AT, created_at); // Created At
// Inserting Row
db.insert(TABLE_LOGIN, null, values);
db.close(); // Closing database connection
/**
* Getting user data from database
* */
public HashMap<String, String> getUserDetails()
HashMap<String,String> user = new HashMap<String,String>();
String selectQuery = "SELECT * FROM " + TABLE_LOGIN;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// Move to first row
cursor.moveToFirst();
if(cursor.getCount() > 0)
Log.i("key_name","value is: " + cursor.getString(1));
Log.i("key_email","value is: " + cursor.getString(2));
Log.i("key_uid","value is: " + cursor.getString(3));
Log.i("key_created_at","value is: " + cursor.getString(4));
cursor.close();
db.close();
// return user
return user;
/**
* Getting user login status
* return true if rows are there in table
* */
public int getRowCount()
String countQuery = "SELECT * FROM " + TABLE_LOGIN;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
int rowCount = cursor.getCount();
db.close();
cursor.close();
// return row count
return rowCount;
her is my fragmentHome class where I want to display the username in a textView:
DatabaseHandler db;
AlertDialogManager alert = new AlertDialogManager();
// Session Manager Class
ArrayList> nameList;
public HomeFragment()
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_home, container, false);
btnViewBars = (Button)rootView.findViewById(R.id.btnViewBars);
btnNewBar = (Button)rootView.findViewById(R.id.btnCreateBar);
// return rootView;
db= new DatabaseHandler(getActivity());
HashMap<String, String> user = db.getUserDetails();
for(int i=0; i<user.size();i++)
username.settext(user.get(i).get("name"));
java android sqlite textview parameter-passing
have you checked that there is data being returned from the query? So is your HashMap being populated?
– john
Jan 31 '14 at 14:40
no I havent because I keep getting this error. my original code (b4 I tried displaying this data) has a login system that uses an online db and sqlite to log users in. when a user logs in it checks the online database and and adds the user to the sqlite database too. unless there is data in the sqlite I don't think the user can log in my login system was designed based on this tutorial link if it can help you understand my situation. My final aim is to display the user currently logged in
– BMC
Jan 31 '14 at 14:59
I could display the user logged in using an intent by storing the user's input in a global variable but . if a user logs in once he gets automatically logged in the next time so after it will returns null because no data was inputed from the user,I am now trying access the sqlite db to retrieve the user currently signed from there
– BMC
Jan 31 '14 at 15:03
just put aLog.i("key","value is: " + cursor.getString(0));
when you docursor.getString(0)
to check what the value is. Also when you get results from a query, the indexing starts at 0 like an array. So instead ofuser.put("name", cursor.getString(1));
it would beuser.put("name", cursor.getString(0));
,user.put("email", cursor.getString(1));
so on and so forth
– john
Jan 31 '14 at 15:08
it Did return the values now how do I show these values in a texview??
– BMC
Jan 31 '14 at 15:58
|
show 1 more comment
I am trying to pass data from an sqlite table to a username textview in my home fragment class, I am having difficulties displaying the data in the textview.
Here is my DatabaseHelper class where all my table is created:
public class DatabaseHandler extends SQLiteOpenHelper {
// All Static variables
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "u168512214_barzd";
// Login table name
private static final String TABLE_LOGIN = "login";
// Login Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_NAME = "name";
private static final String KEY_EMAIL = "email";
private static final String KEY_UID = "uid";
private static final String KEY_CREATED_AT = "created_at";
public DatabaseHandler(Context context)
super(context, DATABASE_NAME, null, DATABASE_VERSION);
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db)
String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_LOGIN + "("
+ KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_NAME + " TEXT,"
+ KEY_EMAIL + " TEXT UNIQUE,"
+ KEY_UID + " TEXT,"
+ KEY_CREATED_AT + " TEXT" + ")";
db.execSQL(CREATE_LOGIN_TABLE);
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOGIN);
// Create tables again
onCreate(db);
/**
* Storing user details in database
* */
public void addUser(String name, String email, String uid, String created_at)
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_NAME, name); // Name
values.put(KEY_EMAIL, email); // Email
values.put(KEY_UID, uid); // Email
values.put(KEY_CREATED_AT, created_at); // Created At
// Inserting Row
db.insert(TABLE_LOGIN, null, values);
db.close(); // Closing database connection
/**
* Getting user data from database
* */
public HashMap<String, String> getUserDetails()
HashMap<String,String> user = new HashMap<String,String>();
String selectQuery = "SELECT * FROM " + TABLE_LOGIN;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// Move to first row
cursor.moveToFirst();
if(cursor.getCount() > 0)
Log.i("key_name","value is: " + cursor.getString(1));
Log.i("key_email","value is: " + cursor.getString(2));
Log.i("key_uid","value is: " + cursor.getString(3));
Log.i("key_created_at","value is: " + cursor.getString(4));
cursor.close();
db.close();
// return user
return user;
/**
* Getting user login status
* return true if rows are there in table
* */
public int getRowCount()
String countQuery = "SELECT * FROM " + TABLE_LOGIN;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
int rowCount = cursor.getCount();
db.close();
cursor.close();
// return row count
return rowCount;
her is my fragmentHome class where I want to display the username in a textView:
DatabaseHandler db;
AlertDialogManager alert = new AlertDialogManager();
// Session Manager Class
ArrayList> nameList;
public HomeFragment()
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_home, container, false);
btnViewBars = (Button)rootView.findViewById(R.id.btnViewBars);
btnNewBar = (Button)rootView.findViewById(R.id.btnCreateBar);
// return rootView;
db= new DatabaseHandler(getActivity());
HashMap<String, String> user = db.getUserDetails();
for(int i=0; i<user.size();i++)
username.settext(user.get(i).get("name"));
java android sqlite textview parameter-passing
I am trying to pass data from an sqlite table to a username textview in my home fragment class, I am having difficulties displaying the data in the textview.
Here is my DatabaseHelper class where all my table is created:
public class DatabaseHandler extends SQLiteOpenHelper {
// All Static variables
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "u168512214_barzd";
// Login table name
private static final String TABLE_LOGIN = "login";
// Login Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_NAME = "name";
private static final String KEY_EMAIL = "email";
private static final String KEY_UID = "uid";
private static final String KEY_CREATED_AT = "created_at";
public DatabaseHandler(Context context)
super(context, DATABASE_NAME, null, DATABASE_VERSION);
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db)
String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_LOGIN + "("
+ KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_NAME + " TEXT,"
+ KEY_EMAIL + " TEXT UNIQUE,"
+ KEY_UID + " TEXT,"
+ KEY_CREATED_AT + " TEXT" + ")";
db.execSQL(CREATE_LOGIN_TABLE);
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOGIN);
// Create tables again
onCreate(db);
/**
* Storing user details in database
* */
public void addUser(String name, String email, String uid, String created_at)
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_NAME, name); // Name
values.put(KEY_EMAIL, email); // Email
values.put(KEY_UID, uid); // Email
values.put(KEY_CREATED_AT, created_at); // Created At
// Inserting Row
db.insert(TABLE_LOGIN, null, values);
db.close(); // Closing database connection
/**
* Getting user data from database
* */
public HashMap<String, String> getUserDetails()
HashMap<String,String> user = new HashMap<String,String>();
String selectQuery = "SELECT * FROM " + TABLE_LOGIN;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// Move to first row
cursor.moveToFirst();
if(cursor.getCount() > 0)
Log.i("key_name","value is: " + cursor.getString(1));
Log.i("key_email","value is: " + cursor.getString(2));
Log.i("key_uid","value is: " + cursor.getString(3));
Log.i("key_created_at","value is: " + cursor.getString(4));
cursor.close();
db.close();
// return user
return user;
/**
* Getting user login status
* return true if rows are there in table
* */
public int getRowCount()
String countQuery = "SELECT * FROM " + TABLE_LOGIN;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
int rowCount = cursor.getCount();
db.close();
cursor.close();
// return row count
return rowCount;
her is my fragmentHome class where I want to display the username in a textView:
DatabaseHandler db;
AlertDialogManager alert = new AlertDialogManager();
// Session Manager Class
ArrayList> nameList;
public HomeFragment()
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_home, container, false);
btnViewBars = (Button)rootView.findViewById(R.id.btnViewBars);
btnNewBar = (Button)rootView.findViewById(R.id.btnCreateBar);
// return rootView;
db= new DatabaseHandler(getActivity());
HashMap<String, String> user = db.getUserDetails();
for(int i=0; i<user.size();i++)
username.settext(user.get(i).get("name"));
java android sqlite textview parameter-passing
java android sqlite textview parameter-passing
edited Mar 7 at 16:59
Cœur
19.1k9114155
19.1k9114155
asked Jan 31 '14 at 14:28
BMCBMC
55
55
have you checked that there is data being returned from the query? So is your HashMap being populated?
– john
Jan 31 '14 at 14:40
no I havent because I keep getting this error. my original code (b4 I tried displaying this data) has a login system that uses an online db and sqlite to log users in. when a user logs in it checks the online database and and adds the user to the sqlite database too. unless there is data in the sqlite I don't think the user can log in my login system was designed based on this tutorial link if it can help you understand my situation. My final aim is to display the user currently logged in
– BMC
Jan 31 '14 at 14:59
I could display the user logged in using an intent by storing the user's input in a global variable but . if a user logs in once he gets automatically logged in the next time so after it will returns null because no data was inputed from the user,I am now trying access the sqlite db to retrieve the user currently signed from there
– BMC
Jan 31 '14 at 15:03
just put aLog.i("key","value is: " + cursor.getString(0));
when you docursor.getString(0)
to check what the value is. Also when you get results from a query, the indexing starts at 0 like an array. So instead ofuser.put("name", cursor.getString(1));
it would beuser.put("name", cursor.getString(0));
,user.put("email", cursor.getString(1));
so on and so forth
– john
Jan 31 '14 at 15:08
it Did return the values now how do I show these values in a texview??
– BMC
Jan 31 '14 at 15:58
|
show 1 more comment
have you checked that there is data being returned from the query? So is your HashMap being populated?
– john
Jan 31 '14 at 14:40
no I havent because I keep getting this error. my original code (b4 I tried displaying this data) has a login system that uses an online db and sqlite to log users in. when a user logs in it checks the online database and and adds the user to the sqlite database too. unless there is data in the sqlite I don't think the user can log in my login system was designed based on this tutorial link if it can help you understand my situation. My final aim is to display the user currently logged in
– BMC
Jan 31 '14 at 14:59
I could display the user logged in using an intent by storing the user's input in a global variable but . if a user logs in once he gets automatically logged in the next time so after it will returns null because no data was inputed from the user,I am now trying access the sqlite db to retrieve the user currently signed from there
– BMC
Jan 31 '14 at 15:03
just put aLog.i("key","value is: " + cursor.getString(0));
when you docursor.getString(0)
to check what the value is. Also when you get results from a query, the indexing starts at 0 like an array. So instead ofuser.put("name", cursor.getString(1));
it would beuser.put("name", cursor.getString(0));
,user.put("email", cursor.getString(1));
so on and so forth
– john
Jan 31 '14 at 15:08
it Did return the values now how do I show these values in a texview??
– BMC
Jan 31 '14 at 15:58
have you checked that there is data being returned from the query? So is your HashMap being populated?
– john
Jan 31 '14 at 14:40
have you checked that there is data being returned from the query? So is your HashMap being populated?
– john
Jan 31 '14 at 14:40
no I havent because I keep getting this error. my original code (b4 I tried displaying this data) has a login system that uses an online db and sqlite to log users in. when a user logs in it checks the online database and and adds the user to the sqlite database too. unless there is data in the sqlite I don't think the user can log in my login system was designed based on this tutorial link if it can help you understand my situation. My final aim is to display the user currently logged in
– BMC
Jan 31 '14 at 14:59
no I havent because I keep getting this error. my original code (b4 I tried displaying this data) has a login system that uses an online db and sqlite to log users in. when a user logs in it checks the online database and and adds the user to the sqlite database too. unless there is data in the sqlite I don't think the user can log in my login system was designed based on this tutorial link if it can help you understand my situation. My final aim is to display the user currently logged in
– BMC
Jan 31 '14 at 14:59
I could display the user logged in using an intent by storing the user's input in a global variable but . if a user logs in once he gets automatically logged in the next time so after it will returns null because no data was inputed from the user,I am now trying access the sqlite db to retrieve the user currently signed from there
– BMC
Jan 31 '14 at 15:03
I could display the user logged in using an intent by storing the user's input in a global variable but . if a user logs in once he gets automatically logged in the next time so after it will returns null because no data was inputed from the user,I am now trying access the sqlite db to retrieve the user currently signed from there
– BMC
Jan 31 '14 at 15:03
just put a
Log.i("key","value is: " + cursor.getString(0));
when you do cursor.getString(0)
to check what the value is. Also when you get results from a query, the indexing starts at 0 like an array. So instead of user.put("name", cursor.getString(1));
it would be user.put("name", cursor.getString(0));
, user.put("email", cursor.getString(1));
so on and so forth– john
Jan 31 '14 at 15:08
just put a
Log.i("key","value is: " + cursor.getString(0));
when you do cursor.getString(0)
to check what the value is. Also when you get results from a query, the indexing starts at 0 like an array. So instead of user.put("name", cursor.getString(1));
it would be user.put("name", cursor.getString(0));
, user.put("email", cursor.getString(1));
so on and so forth– john
Jan 31 '14 at 15:08
it Did return the values now how do I show these values in a texview??
– BMC
Jan 31 '14 at 15:58
it Did return the values now how do I show these values in a texview??
– BMC
Jan 31 '14 at 15:58
|
show 1 more comment
0
active
oldest
votes
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f21482422%2fpassing-data-from-sqlite-to-a-textview%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f21482422%2fpassing-data-from-sqlite-to-a-textview%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
have you checked that there is data being returned from the query? So is your HashMap being populated?
– john
Jan 31 '14 at 14:40
no I havent because I keep getting this error. my original code (b4 I tried displaying this data) has a login system that uses an online db and sqlite to log users in. when a user logs in it checks the online database and and adds the user to the sqlite database too. unless there is data in the sqlite I don't think the user can log in my login system was designed based on this tutorial link if it can help you understand my situation. My final aim is to display the user currently logged in
– BMC
Jan 31 '14 at 14:59
I could display the user logged in using an intent by storing the user's input in a global variable but . if a user logs in once he gets automatically logged in the next time so after it will returns null because no data was inputed from the user,I am now trying access the sqlite db to retrieve the user currently signed from there
– BMC
Jan 31 '14 at 15:03
just put a
Log.i("key","value is: " + cursor.getString(0));
when you docursor.getString(0)
to check what the value is. Also when you get results from a query, the indexing starts at 0 like an array. So instead ofuser.put("name", cursor.getString(1));
it would beuser.put("name", cursor.getString(0));
,user.put("email", cursor.getString(1));
so on and so forth– john
Jan 31 '14 at 15:08
it Did return the values now how do I show these values in a texview??
– BMC
Jan 31 '14 at 15:58