android


I have got a nullpointer exception


hi i have created an application in android but on running I am getting a null pointer exception
I am giving my log cat and java class below I need a better solution to overcome this error
08-23 10:09:57.426: E/AndroidRuntime(3373): FATAL EXCEPTION: main
08-23 10:09:57.426: E/AndroidRuntime(3373): java.lang.RuntimeException: Unable to start
activity ComponentInfo{com.neochat/com.neochat.Friends_list}:java.lang.NullPointerException
08-23 10:09:57.426: E/AndroidRuntime(3373):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
08-23 10:09:57.426: E/AndroidRuntime(3373): at android.app.ActivityThread.startActivityNow(ActivityThread.java:2023)
08-23 10:09:57.426: E/AndroidRuntime(3373): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)`
Here is my java class
public class Friends_list extends Activity implements OnItemClickListener{
private ArrayList<String> results = new ArrayList<String>();
private SQLiteDatabase newDB;
LoginDataBaseAdapter loginDataBaseAdapter ;
ListView listview;
Context context;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_friends);
listview=(ListView)findViewById(R.id.listview);
context=this;
loginDataBaseAdapter.getfriends();
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3)
{
Intent in2=new
Intent(Friends_list.this,InboxActivity.class);
startActivity(in2);
}
}
I am giving my getFriends() function below
public List<String>getfriends(){
List<String> FriendList=new ArrayList<String>();
String selectQuery="select * from UserDetails";
db=dbHelper.getWritableDatabase();
Cursor cursor=db.rawQuery(selectQuery, null);
while(cursor.moveToNext()){
FriendList.add(cursor.getString(1));
}
return FriendList;
}
I want to display the contents of the table in the database to a listview in my activity can anybody help me
you are accessing loginDataBaseAdapter without initialize it
loginDataBaseAdapter = new ....
loginDataBaseAdapter.getfriends();
inside onCreate add below line
LoginDataBaseAdapter loginDataBaseAdapter = new LoginDataBaseAdapter(this);

Related Links

onAnimationUpdate: height does not change after device is rotated
Cast Session terminates with error code 2005
Change the background of a CollapsingToolabarLayout
Google Sign-In Failed Android
code to enable a setting of Android developer mode [duplicate]
Error while inserting values in db [duplicate]
How to use libjpeg-turbo to decode JPEG9 Image?
Play .mov Video file in Android
Is there a way to give a List to a Fragment from just a java class (Not an activity or fragment)
Unable to deserialize object from xml file xamarin forms
Clicking any Settings menu in Google Keyboard causes crash
android: how to resize the dialog progress drawables
ATTACH DATABASE gives “database is already in use” on Android
Images don't render on device in react native
How possible is it for Retrofit to pull 50k data?
How can i handle push notification in IMF8?

Categories

HOME
pda
ns-3
apache-spark-mllib
nuget
r-googlesheets
aws-cli
mips
iis-6
opengl-3
nstableheaderview
character
barcode
joomla3.0
little-proxy
watson-conversation
mod-security
alamofire
emoji
ycsb
nancy
radgridview
dimensional-modeling
fileserver
template-engine
xmonad
ksh
backpack-for-laravel
monit
pylons
ms-access-2003
underscore.js
sqsh
volatile
catch-unit-test
sql-server-ce
playframework-2.1
opensmpp
plaintext
uiimage
httr
optimizely
puredata
servermanager
mongotemplate
podscms
trojan
carrot2
reindex
avx
css-transforms
py2neo
mathcad
redistributable
preprocessor
tinkerpop3
flex4.6
ng-grid
gogs
firebase-security
kango-framework
upx
highland.js
inf
boomerang
gocql
avisynth
lazybones
rpart
batik
eoferror
viola-jones
liquid-layout
bufferedinputstream
android-broadcast
execve
boost-program-options
uncaught-typeerror
post-commit-hook
jama
gae-quotas
gwt-openlayers
light
gpars
merb
epiceditor
mysql-error-2013
robotlegs
redis-py
zope.interface
extconf.rb
xcelsius
rmdir
metaweblog
drupal-fivestar
silverlight-oob
visualj#
complex-event-processing
flvplayback

Resources

Encrypt Message