How do i fix this SQLite java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Android database recreates every time application is launchedWhy does my exception handler not trap Android SQLite insert error?Cursor for database on sdcard not closing or deactiveandroid java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindowjava - java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindowjava.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindowjava.lang.IllegalStateException: Couldn't read row 0, col 2 from CursorWindowjava.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindowandroid java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindowAndroid sqlite unable to read after updating a blob

How to Make a Beautiful Stacked 3D Plot

Do I really need to have a message in a novel to appeal to readers?

Can anything be seen from the center of the Boötes void? How dark would it be?

Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?

How would a mousetrap for use in space work?

If a VARCHAR(MAX) column is included in an index, is the entire value always stored in the index page(s)?

How can I use the Python library networkx from Mathematica?

Should I use a zero-interest credit card for a large one-time purchase?

What is the escape velocity of a neutron particle (not neutron star)

Do I really need recursive chmod to restrict access to a folder?

How come Sam didn't become Lord of Horn Hill?

Do wooden building fires get hotter than 600°C?

When the Haste spell ends on a creature, do attackers have advantage against that creature?

Fundamental Solution of the Pell Equation

How to compare two different files line by line in unix?

Using audio cues to encourage good posture

Can you use the Shield Master feat to shove someone before you make an attack by using a Readied action?

Is it cost-effective to upgrade an old-ish Giant Escape R3 commuter bike with entry-level branded parts (wheels, drivetrain)?

If my PI received research grants from a company to be able to pay my postdoc salary, did I have a potential conflict interest too?

Why didn't Eitri join the fight?

An adverb for when you're not exaggerating

Do square wave exist?

Is it fair for a professor to grade us on the possession of past papers?

Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?



How do i fix this SQLite java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Android database recreates every time application is launchedWhy does my exception handler not trap Android SQLite insert error?Cursor for database on sdcard not closing or deactiveandroid java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindowjava - java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindowjava.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindowjava.lang.IllegalStateException: Couldn't read row 0, col 2 from CursorWindowjava.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindowandroid java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindowAndroid sqlite unable to read after updating a blob



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-2
















FATAL EXCEPTION: main
Process: example.myproject, PID: 2608
java.lang.RuntimeException: Unable to start activity ComponentInfoedgedev.andelaproject/example.myproject.Activites_and_Fragments.MainActivity: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.




In MyDB.class (subclass of SQLiteOpenHelper):



Here is my Table Statement



String create_table = "CREATE TABLE my_table_of_profiles (profile_id INTEGER, username TEXT, profile TEXT, image TEXT, score TEXT ) "; 

@Override
public void onCreate(SQLiteDatabase db)
db.execSQL(create_table);



in my DatabaseAccessObject.class:



public ArrayList<Profile> getEntriesFromDB(Context context) 

SQLiteDatabase db = new MyDB(context).getWritableDatabase();

Cursor cursor = db.query("my_table_of_profiles" , null, null, null, null, null, null);
Profile profile;
ArrayList<Profile> profiles = new ArrayList<>();


while (cursor.moveToNext())

/*Here is -> DatabaseAccessObject.java:69*/ int a = cursor.getInt(cursor.getColumnIndex("profile_id");
String b= cursor.getString(cursor.getColumnIndex("username");
String c= cursor.getString(cursor.getColumnIndex("profile");
String d= cursor.getString(cursor.getColumnIndex("image");
Double e = Double.parseDouble(cursor.getString(cursor.getColumnIndex("score");


profile = new Profile(a,b,c,d,e );
profiles.add(profile);

cursor.close();
db.close();
return profiles;

public boolean storeProfiles (Context context, ArrayList<Profile> profile)
SQLiteDatabase db = new MyDB(context).getWritableDatabase();
db.beginTransaction();
for(Profile freshProfile : profile)

ContentValues cv = new ContentValues();
cv.put("id", freshProfile.getProfile_id());
cv.put("username", freshProfile.getProfile_username());
cv.put("profile", freshProfile.getProfile_url());
cv.put("image", freshProfile.getImage_url());
cv.put("score", freshProfile.getScore());

long result = db.insert("my_table_of_profiles", null, cv);

if (result < 0)
return false;


db.setTransactionSuccessful();
db.endTransaction();
db.close();
return true;



Profile.class



public class Profile 
private int profile_id;
private String profile_username;
private String profile_url;
private String image_url;
private Double score;


public Profile(int profile_id, String profile_username, String profile_url, String image_url, Double score )

this.image_url = image_url;
this.profile_username = profile_username;
this.profile_url = profile_url;
this.profile_id = profile_id;
this.score = score;



public String getImage_url()
return image_url;


public String profile_username()
return profile_username;


public String getProfile_url()
return profile_url;


public int getProfile_id()
return profile_id;


public String getScore()
return ""+round(score);


private double round(double value)
long factor = (long) Math.pow(10,3);
value = value * factor;
long tmp = Math.round(value);

return (double) tmp/factor;





In MainActivity.java (Inside OnCreate method), i put some dummy data:



Profile profile;
ArrayList<Profile> profiles = new ArrayList<>();

for (int i=0 ; i<20; i++)
profile = new Profile(i,"username"+i, "http:///www.url.com"+i,"imgur.com/abcdefgh", 1.234);

profiles.add(profile);


new DatabaseAccessObject().storePosts(this, profiles);
ArrayList<Profile> retrieved = DatabaseAccessObject.getsInstance().getEntriesFromDB(this);
// i also tried to retrieve the items from the database
//This is where i got an Error


an Excerpt of the Error i got :




Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
at android.database.CursorWindow.nativeGetLong(Native Method)
at android.database.CursorWindow.getLong(CursorWindow.java:511)
at android.database.CursorWindow.getInt(CursorWindow.java:578)
at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:69)
at edgedev.andelaproject.Database.DatabaseAccessObject.getEntriesFromDB(DatabaseAccessObject.java:69)
at edgedev.andelaproject.Database.DatabaseAccessObject.storePosts(DatabaseAccessObject.java:26)
at edgedev.andelaproject.Activites_and_Fragments.MainActivity.onCreate(MainActivity.java:71)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)











share|improve this question



















  • 1





    cursor.getColumnIndex("id") is returning -1 because "id" is not a valid column name. Look at your CREATE statement.

    – Mike M.
    Mar 7 '17 at 17:35












  • @MikeM. lemme check again, i used "profile_id", still getting the same error

    – Micklo_Nerd
    Mar 7 '17 at 17:37












  • @Rotwang, i intend getting all the column

    – Micklo_Nerd
    Mar 7 '17 at 17:38











  • Hey! did you solved this?

    – Hardik Joshi
    Jul 22 '17 at 16:56











  • @HardikJoshi, Yeah i did solve the issue. It was a typo in my code, Silly Me

    – Micklo_Nerd
    Aug 12 '17 at 15:09


















-2
















FATAL EXCEPTION: main
Process: example.myproject, PID: 2608
java.lang.RuntimeException: Unable to start activity ComponentInfoedgedev.andelaproject/example.myproject.Activites_and_Fragments.MainActivity: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.




In MyDB.class (subclass of SQLiteOpenHelper):



Here is my Table Statement



String create_table = "CREATE TABLE my_table_of_profiles (profile_id INTEGER, username TEXT, profile TEXT, image TEXT, score TEXT ) "; 

@Override
public void onCreate(SQLiteDatabase db)
db.execSQL(create_table);



in my DatabaseAccessObject.class:



public ArrayList<Profile> getEntriesFromDB(Context context) 

SQLiteDatabase db = new MyDB(context).getWritableDatabase();

Cursor cursor = db.query("my_table_of_profiles" , null, null, null, null, null, null);
Profile profile;
ArrayList<Profile> profiles = new ArrayList<>();


while (cursor.moveToNext())

/*Here is -> DatabaseAccessObject.java:69*/ int a = cursor.getInt(cursor.getColumnIndex("profile_id");
String b= cursor.getString(cursor.getColumnIndex("username");
String c= cursor.getString(cursor.getColumnIndex("profile");
String d= cursor.getString(cursor.getColumnIndex("image");
Double e = Double.parseDouble(cursor.getString(cursor.getColumnIndex("score");


profile = new Profile(a,b,c,d,e );
profiles.add(profile);

cursor.close();
db.close();
return profiles;

public boolean storeProfiles (Context context, ArrayList<Profile> profile)
SQLiteDatabase db = new MyDB(context).getWritableDatabase();
db.beginTransaction();
for(Profile freshProfile : profile)

ContentValues cv = new ContentValues();
cv.put("id", freshProfile.getProfile_id());
cv.put("username", freshProfile.getProfile_username());
cv.put("profile", freshProfile.getProfile_url());
cv.put("image", freshProfile.getImage_url());
cv.put("score", freshProfile.getScore());

long result = db.insert("my_table_of_profiles", null, cv);

if (result < 0)
return false;


db.setTransactionSuccessful();
db.endTransaction();
db.close();
return true;



Profile.class



public class Profile 
private int profile_id;
private String profile_username;
private String profile_url;
private String image_url;
private Double score;


public Profile(int profile_id, String profile_username, String profile_url, String image_url, Double score )

this.image_url = image_url;
this.profile_username = profile_username;
this.profile_url = profile_url;
this.profile_id = profile_id;
this.score = score;



public String getImage_url()
return image_url;


public String profile_username()
return profile_username;


public String getProfile_url()
return profile_url;


public int getProfile_id()
return profile_id;


public String getScore()
return ""+round(score);


private double round(double value)
long factor = (long) Math.pow(10,3);
value = value * factor;
long tmp = Math.round(value);

return (double) tmp/factor;





In MainActivity.java (Inside OnCreate method), i put some dummy data:



Profile profile;
ArrayList<Profile> profiles = new ArrayList<>();

for (int i=0 ; i<20; i++)
profile = new Profile(i,"username"+i, "http:///www.url.com"+i,"imgur.com/abcdefgh", 1.234);

profiles.add(profile);


new DatabaseAccessObject().storePosts(this, profiles);
ArrayList<Profile> retrieved = DatabaseAccessObject.getsInstance().getEntriesFromDB(this);
// i also tried to retrieve the items from the database
//This is where i got an Error


an Excerpt of the Error i got :




Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
at android.database.CursorWindow.nativeGetLong(Native Method)
at android.database.CursorWindow.getLong(CursorWindow.java:511)
at android.database.CursorWindow.getInt(CursorWindow.java:578)
at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:69)
at edgedev.andelaproject.Database.DatabaseAccessObject.getEntriesFromDB(DatabaseAccessObject.java:69)
at edgedev.andelaproject.Database.DatabaseAccessObject.storePosts(DatabaseAccessObject.java:26)
at edgedev.andelaproject.Activites_and_Fragments.MainActivity.onCreate(MainActivity.java:71)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)











share|improve this question



















  • 1





    cursor.getColumnIndex("id") is returning -1 because "id" is not a valid column name. Look at your CREATE statement.

    – Mike M.
    Mar 7 '17 at 17:35












  • @MikeM. lemme check again, i used "profile_id", still getting the same error

    – Micklo_Nerd
    Mar 7 '17 at 17:37












  • @Rotwang, i intend getting all the column

    – Micklo_Nerd
    Mar 7 '17 at 17:38











  • Hey! did you solved this?

    – Hardik Joshi
    Jul 22 '17 at 16:56











  • @HardikJoshi, Yeah i did solve the issue. It was a typo in my code, Silly Me

    – Micklo_Nerd
    Aug 12 '17 at 15:09














-2












-2








-2









FATAL EXCEPTION: main
Process: example.myproject, PID: 2608
java.lang.RuntimeException: Unable to start activity ComponentInfoedgedev.andelaproject/example.myproject.Activites_and_Fragments.MainActivity: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.




In MyDB.class (subclass of SQLiteOpenHelper):



Here is my Table Statement



String create_table = "CREATE TABLE my_table_of_profiles (profile_id INTEGER, username TEXT, profile TEXT, image TEXT, score TEXT ) "; 

@Override
public void onCreate(SQLiteDatabase db)
db.execSQL(create_table);



in my DatabaseAccessObject.class:



public ArrayList<Profile> getEntriesFromDB(Context context) 

SQLiteDatabase db = new MyDB(context).getWritableDatabase();

Cursor cursor = db.query("my_table_of_profiles" , null, null, null, null, null, null);
Profile profile;
ArrayList<Profile> profiles = new ArrayList<>();


while (cursor.moveToNext())

/*Here is -> DatabaseAccessObject.java:69*/ int a = cursor.getInt(cursor.getColumnIndex("profile_id");
String b= cursor.getString(cursor.getColumnIndex("username");
String c= cursor.getString(cursor.getColumnIndex("profile");
String d= cursor.getString(cursor.getColumnIndex("image");
Double e = Double.parseDouble(cursor.getString(cursor.getColumnIndex("score");


profile = new Profile(a,b,c,d,e );
profiles.add(profile);

cursor.close();
db.close();
return profiles;

public boolean storeProfiles (Context context, ArrayList<Profile> profile)
SQLiteDatabase db = new MyDB(context).getWritableDatabase();
db.beginTransaction();
for(Profile freshProfile : profile)

ContentValues cv = new ContentValues();
cv.put("id", freshProfile.getProfile_id());
cv.put("username", freshProfile.getProfile_username());
cv.put("profile", freshProfile.getProfile_url());
cv.put("image", freshProfile.getImage_url());
cv.put("score", freshProfile.getScore());

long result = db.insert("my_table_of_profiles", null, cv);

if (result < 0)
return false;


db.setTransactionSuccessful();
db.endTransaction();
db.close();
return true;



Profile.class



public class Profile 
private int profile_id;
private String profile_username;
private String profile_url;
private String image_url;
private Double score;


public Profile(int profile_id, String profile_username, String profile_url, String image_url, Double score )

this.image_url = image_url;
this.profile_username = profile_username;
this.profile_url = profile_url;
this.profile_id = profile_id;
this.score = score;



public String getImage_url()
return image_url;


public String profile_username()
return profile_username;


public String getProfile_url()
return profile_url;


public int getProfile_id()
return profile_id;


public String getScore()
return ""+round(score);


private double round(double value)
long factor = (long) Math.pow(10,3);
value = value * factor;
long tmp = Math.round(value);

return (double) tmp/factor;





In MainActivity.java (Inside OnCreate method), i put some dummy data:



Profile profile;
ArrayList<Profile> profiles = new ArrayList<>();

for (int i=0 ; i<20; i++)
profile = new Profile(i,"username"+i, "http:///www.url.com"+i,"imgur.com/abcdefgh", 1.234);

profiles.add(profile);


new DatabaseAccessObject().storePosts(this, profiles);
ArrayList<Profile> retrieved = DatabaseAccessObject.getsInstance().getEntriesFromDB(this);
// i also tried to retrieve the items from the database
//This is where i got an Error


an Excerpt of the Error i got :




Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
at android.database.CursorWindow.nativeGetLong(Native Method)
at android.database.CursorWindow.getLong(CursorWindow.java:511)
at android.database.CursorWindow.getInt(CursorWindow.java:578)
at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:69)
at edgedev.andelaproject.Database.DatabaseAccessObject.getEntriesFromDB(DatabaseAccessObject.java:69)
at edgedev.andelaproject.Database.DatabaseAccessObject.storePosts(DatabaseAccessObject.java:26)
at edgedev.andelaproject.Activites_and_Fragments.MainActivity.onCreate(MainActivity.java:71)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)











share|improve this question

















FATAL EXCEPTION: main
Process: example.myproject, PID: 2608
java.lang.RuntimeException: Unable to start activity ComponentInfoedgedev.andelaproject/example.myproject.Activites_and_Fragments.MainActivity: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.




In MyDB.class (subclass of SQLiteOpenHelper):



Here is my Table Statement



String create_table = "CREATE TABLE my_table_of_profiles (profile_id INTEGER, username TEXT, profile TEXT, image TEXT, score TEXT ) "; 

@Override
public void onCreate(SQLiteDatabase db)
db.execSQL(create_table);



in my DatabaseAccessObject.class:



public ArrayList<Profile> getEntriesFromDB(Context context) 

SQLiteDatabase db = new MyDB(context).getWritableDatabase();

Cursor cursor = db.query("my_table_of_profiles" , null, null, null, null, null, null);
Profile profile;
ArrayList<Profile> profiles = new ArrayList<>();


while (cursor.moveToNext())

/*Here is -> DatabaseAccessObject.java:69*/ int a = cursor.getInt(cursor.getColumnIndex("profile_id");
String b= cursor.getString(cursor.getColumnIndex("username");
String c= cursor.getString(cursor.getColumnIndex("profile");
String d= cursor.getString(cursor.getColumnIndex("image");
Double e = Double.parseDouble(cursor.getString(cursor.getColumnIndex("score");


profile = new Profile(a,b,c,d,e );
profiles.add(profile);

cursor.close();
db.close();
return profiles;

public boolean storeProfiles (Context context, ArrayList<Profile> profile)
SQLiteDatabase db = new MyDB(context).getWritableDatabase();
db.beginTransaction();
for(Profile freshProfile : profile)

ContentValues cv = new ContentValues();
cv.put("id", freshProfile.getProfile_id());
cv.put("username", freshProfile.getProfile_username());
cv.put("profile", freshProfile.getProfile_url());
cv.put("image", freshProfile.getImage_url());
cv.put("score", freshProfile.getScore());

long result = db.insert("my_table_of_profiles", null, cv);

if (result < 0)
return false;


db.setTransactionSuccessful();
db.endTransaction();
db.close();
return true;



Profile.class



public class Profile 
private int profile_id;
private String profile_username;
private String profile_url;
private String image_url;
private Double score;


public Profile(int profile_id, String profile_username, String profile_url, String image_url, Double score )

this.image_url = image_url;
this.profile_username = profile_username;
this.profile_url = profile_url;
this.profile_id = profile_id;
this.score = score;



public String getImage_url()
return image_url;


public String profile_username()
return profile_username;


public String getProfile_url()
return profile_url;


public int getProfile_id()
return profile_id;


public String getScore()
return ""+round(score);


private double round(double value)
long factor = (long) Math.pow(10,3);
value = value * factor;
long tmp = Math.round(value);

return (double) tmp/factor;





In MainActivity.java (Inside OnCreate method), i put some dummy data:



Profile profile;
ArrayList<Profile> profiles = new ArrayList<>();

for (int i=0 ; i<20; i++)
profile = new Profile(i,"username"+i, "http:///www.url.com"+i,"imgur.com/abcdefgh", 1.234);

profiles.add(profile);


new DatabaseAccessObject().storePosts(this, profiles);
ArrayList<Profile> retrieved = DatabaseAccessObject.getsInstance().getEntriesFromDB(this);
// i also tried to retrieve the items from the database
//This is where i got an Error


an Excerpt of the Error i got :




Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
at android.database.CursorWindow.nativeGetLong(Native Method)
at android.database.CursorWindow.getLong(CursorWindow.java:511)
at android.database.CursorWindow.getInt(CursorWindow.java:578)
at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:69)
at edgedev.andelaproject.Database.DatabaseAccessObject.getEntriesFromDB(DatabaseAccessObject.java:69)
at edgedev.andelaproject.Database.DatabaseAccessObject.storePosts(DatabaseAccessObject.java:26)
at edgedev.andelaproject.Activites_and_Fragments.MainActivity.onCreate(MainActivity.java:71)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)








android sqlite android-sqlite android-database






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 '17 at 18:24







Micklo_Nerd

















asked Mar 7 '17 at 17:30









Micklo_NerdMicklo_Nerd

544513




544513







  • 1





    cursor.getColumnIndex("id") is returning -1 because "id" is not a valid column name. Look at your CREATE statement.

    – Mike M.
    Mar 7 '17 at 17:35












  • @MikeM. lemme check again, i used "profile_id", still getting the same error

    – Micklo_Nerd
    Mar 7 '17 at 17:37












  • @Rotwang, i intend getting all the column

    – Micklo_Nerd
    Mar 7 '17 at 17:38











  • Hey! did you solved this?

    – Hardik Joshi
    Jul 22 '17 at 16:56











  • @HardikJoshi, Yeah i did solve the issue. It was a typo in my code, Silly Me

    – Micklo_Nerd
    Aug 12 '17 at 15:09













  • 1





    cursor.getColumnIndex("id") is returning -1 because "id" is not a valid column name. Look at your CREATE statement.

    – Mike M.
    Mar 7 '17 at 17:35












  • @MikeM. lemme check again, i used "profile_id", still getting the same error

    – Micklo_Nerd
    Mar 7 '17 at 17:37












  • @Rotwang, i intend getting all the column

    – Micklo_Nerd
    Mar 7 '17 at 17:38











  • Hey! did you solved this?

    – Hardik Joshi
    Jul 22 '17 at 16:56











  • @HardikJoshi, Yeah i did solve the issue. It was a typo in my code, Silly Me

    – Micklo_Nerd
    Aug 12 '17 at 15:09








1




1





cursor.getColumnIndex("id") is returning -1 because "id" is not a valid column name. Look at your CREATE statement.

– Mike M.
Mar 7 '17 at 17:35






cursor.getColumnIndex("id") is returning -1 because "id" is not a valid column name. Look at your CREATE statement.

– Mike M.
Mar 7 '17 at 17:35














@MikeM. lemme check again, i used "profile_id", still getting the same error

– Micklo_Nerd
Mar 7 '17 at 17:37






@MikeM. lemme check again, i used "profile_id", still getting the same error

– Micklo_Nerd
Mar 7 '17 at 17:37














@Rotwang, i intend getting all the column

– Micklo_Nerd
Mar 7 '17 at 17:38





@Rotwang, i intend getting all the column

– Micklo_Nerd
Mar 7 '17 at 17:38













Hey! did you solved this?

– Hardik Joshi
Jul 22 '17 at 16:56





Hey! did you solved this?

– Hardik Joshi
Jul 22 '17 at 16:56













@HardikJoshi, Yeah i did solve the issue. It was a typo in my code, Silly Me

– Micklo_Nerd
Aug 12 '17 at 15:09






@HardikJoshi, Yeah i did solve the issue. It was a typo in my code, Silly Me

– Micklo_Nerd
Aug 12 '17 at 15:09













2 Answers
2






active

oldest

votes


















2














int a = cursor.getInt(cursor.getColumnIndex("id");


You don't have a column id.



It should be profile_id :



int a = cursor.getInt(cursor.getColumnIndex("profile_id");


Don't forget to reinstall the app after you make this change.






share|improve this answer

























  • I have changed it to, String create_table = "CREATE TABLE my_table_of_profiles (profile_id INTEGER, username TEXT, profile TEXT, image TEXT, score TEXT ) ". int a = cursor.getInt(cursor.getColumnIndex("profile_id") still getting the same error

    – Micklo_Nerd
    Mar 7 '17 at 17:42












  • @Micklo_Nerd Did you uninstall and reinstall the app?

    – Abhishek Jain
    Mar 7 '17 at 17:44











  • ooh! lemme try that now!

    – Micklo_Nerd
    Mar 7 '17 at 17:45











  • I uninstalled the app and reinstalled again, same error occured

    – Micklo_Nerd
    Mar 7 '17 at 17:48











  • Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.at example.myproject.Database.DatabaseAccessObject.getEntriesFromDB(DatabaseAccessObject.java:69)

    – Micklo_Nerd
    Mar 7 '17 at 17:49



















0















Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing




happened to me in an Android studio/Kotlin project today



the problem was



I was inserting



col1
col2
col3
col4
col5



but in other class I had an arrayOf (col1 col2 col3) only (same database) adding col4 col5 solved the problem I know is not a direct answer just only to ilustrate the error itself that is not related with windowcursor and or .movetofirst



hope this help a little






share|improve this answer























    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%2f42654572%2fhow-do-i-fix-this-sqlite-java-lang-illegalstateexception-couldnt-read-row-0-c%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    int a = cursor.getInt(cursor.getColumnIndex("id");


    You don't have a column id.



    It should be profile_id :



    int a = cursor.getInt(cursor.getColumnIndex("profile_id");


    Don't forget to reinstall the app after you make this change.






    share|improve this answer

























    • I have changed it to, String create_table = "CREATE TABLE my_table_of_profiles (profile_id INTEGER, username TEXT, profile TEXT, image TEXT, score TEXT ) ". int a = cursor.getInt(cursor.getColumnIndex("profile_id") still getting the same error

      – Micklo_Nerd
      Mar 7 '17 at 17:42












    • @Micklo_Nerd Did you uninstall and reinstall the app?

      – Abhishek Jain
      Mar 7 '17 at 17:44











    • ooh! lemme try that now!

      – Micklo_Nerd
      Mar 7 '17 at 17:45











    • I uninstalled the app and reinstalled again, same error occured

      – Micklo_Nerd
      Mar 7 '17 at 17:48











    • Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.at example.myproject.Database.DatabaseAccessObject.getEntriesFromDB(DatabaseAccessObject.java:69)

      – Micklo_Nerd
      Mar 7 '17 at 17:49
















    2














    int a = cursor.getInt(cursor.getColumnIndex("id");


    You don't have a column id.



    It should be profile_id :



    int a = cursor.getInt(cursor.getColumnIndex("profile_id");


    Don't forget to reinstall the app after you make this change.






    share|improve this answer

























    • I have changed it to, String create_table = "CREATE TABLE my_table_of_profiles (profile_id INTEGER, username TEXT, profile TEXT, image TEXT, score TEXT ) ". int a = cursor.getInt(cursor.getColumnIndex("profile_id") still getting the same error

      – Micklo_Nerd
      Mar 7 '17 at 17:42












    • @Micklo_Nerd Did you uninstall and reinstall the app?

      – Abhishek Jain
      Mar 7 '17 at 17:44











    • ooh! lemme try that now!

      – Micklo_Nerd
      Mar 7 '17 at 17:45











    • I uninstalled the app and reinstalled again, same error occured

      – Micklo_Nerd
      Mar 7 '17 at 17:48











    • Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.at example.myproject.Database.DatabaseAccessObject.getEntriesFromDB(DatabaseAccessObject.java:69)

      – Micklo_Nerd
      Mar 7 '17 at 17:49














    2












    2








    2







    int a = cursor.getInt(cursor.getColumnIndex("id");


    You don't have a column id.



    It should be profile_id :



    int a = cursor.getInt(cursor.getColumnIndex("profile_id");


    Don't forget to reinstall the app after you make this change.






    share|improve this answer















    int a = cursor.getInt(cursor.getColumnIndex("id");


    You don't have a column id.



    It should be profile_id :



    int a = cursor.getInt(cursor.getColumnIndex("profile_id");


    Don't forget to reinstall the app after you make this change.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 7 '17 at 17:45

























    answered Mar 7 '17 at 17:37









    Abhishek JainAbhishek Jain

    2,50811634




    2,50811634












    • I have changed it to, String create_table = "CREATE TABLE my_table_of_profiles (profile_id INTEGER, username TEXT, profile TEXT, image TEXT, score TEXT ) ". int a = cursor.getInt(cursor.getColumnIndex("profile_id") still getting the same error

      – Micklo_Nerd
      Mar 7 '17 at 17:42












    • @Micklo_Nerd Did you uninstall and reinstall the app?

      – Abhishek Jain
      Mar 7 '17 at 17:44











    • ooh! lemme try that now!

      – Micklo_Nerd
      Mar 7 '17 at 17:45











    • I uninstalled the app and reinstalled again, same error occured

      – Micklo_Nerd
      Mar 7 '17 at 17:48











    • Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.at example.myproject.Database.DatabaseAccessObject.getEntriesFromDB(DatabaseAccessObject.java:69)

      – Micklo_Nerd
      Mar 7 '17 at 17:49


















    • I have changed it to, String create_table = "CREATE TABLE my_table_of_profiles (profile_id INTEGER, username TEXT, profile TEXT, image TEXT, score TEXT ) ". int a = cursor.getInt(cursor.getColumnIndex("profile_id") still getting the same error

      – Micklo_Nerd
      Mar 7 '17 at 17:42












    • @Micklo_Nerd Did you uninstall and reinstall the app?

      – Abhishek Jain
      Mar 7 '17 at 17:44











    • ooh! lemme try that now!

      – Micklo_Nerd
      Mar 7 '17 at 17:45











    • I uninstalled the app and reinstalled again, same error occured

      – Micklo_Nerd
      Mar 7 '17 at 17:48











    • Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.at example.myproject.Database.DatabaseAccessObject.getEntriesFromDB(DatabaseAccessObject.java:69)

      – Micklo_Nerd
      Mar 7 '17 at 17:49

















    I have changed it to, String create_table = "CREATE TABLE my_table_of_profiles (profile_id INTEGER, username TEXT, profile TEXT, image TEXT, score TEXT ) ". int a = cursor.getInt(cursor.getColumnIndex("profile_id") still getting the same error

    – Micklo_Nerd
    Mar 7 '17 at 17:42






    I have changed it to, String create_table = "CREATE TABLE my_table_of_profiles (profile_id INTEGER, username TEXT, profile TEXT, image TEXT, score TEXT ) ". int a = cursor.getInt(cursor.getColumnIndex("profile_id") still getting the same error

    – Micklo_Nerd
    Mar 7 '17 at 17:42














    @Micklo_Nerd Did you uninstall and reinstall the app?

    – Abhishek Jain
    Mar 7 '17 at 17:44





    @Micklo_Nerd Did you uninstall and reinstall the app?

    – Abhishek Jain
    Mar 7 '17 at 17:44













    ooh! lemme try that now!

    – Micklo_Nerd
    Mar 7 '17 at 17:45





    ooh! lemme try that now!

    – Micklo_Nerd
    Mar 7 '17 at 17:45













    I uninstalled the app and reinstalled again, same error occured

    – Micklo_Nerd
    Mar 7 '17 at 17:48





    I uninstalled the app and reinstalled again, same error occured

    – Micklo_Nerd
    Mar 7 '17 at 17:48













    Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.at example.myproject.Database.DatabaseAccessObject.getEntriesFromDB(DatabaseAccessObject.java:69)

    – Micklo_Nerd
    Mar 7 '17 at 17:49






    Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.at example.myproject.Database.DatabaseAccessObject.getEntriesFromDB(DatabaseAccessObject.java:69)

    – Micklo_Nerd
    Mar 7 '17 at 17:49














    0















    Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing




    happened to me in an Android studio/Kotlin project today



    the problem was



    I was inserting



    col1
    col2
    col3
    col4
    col5



    but in other class I had an arrayOf (col1 col2 col3) only (same database) adding col4 col5 solved the problem I know is not a direct answer just only to ilustrate the error itself that is not related with windowcursor and or .movetofirst



    hope this help a little






    share|improve this answer



























      0















      Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing




      happened to me in an Android studio/Kotlin project today



      the problem was



      I was inserting



      col1
      col2
      col3
      col4
      col5



      but in other class I had an arrayOf (col1 col2 col3) only (same database) adding col4 col5 solved the problem I know is not a direct answer just only to ilustrate the error itself that is not related with windowcursor and or .movetofirst



      hope this help a little






      share|improve this answer

























        0












        0








        0








        Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing




        happened to me in an Android studio/Kotlin project today



        the problem was



        I was inserting



        col1
        col2
        col3
        col4
        col5



        but in other class I had an arrayOf (col1 col2 col3) only (same database) adding col4 col5 solved the problem I know is not a direct answer just only to ilustrate the error itself that is not related with windowcursor and or .movetofirst



        hope this help a little






        share|improve this answer














        Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing




        happened to me in an Android studio/Kotlin project today



        the problem was



        I was inserting



        col1
        col2
        col3
        col4
        col5



        but in other class I had an arrayOf (col1 col2 col3) only (same database) adding col4 col5 solved the problem I know is not a direct answer just only to ilustrate the error itself that is not related with windowcursor and or .movetofirst



        hope this help a little







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 18:49









        MarkTMarkT

        112




        112



























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42654572%2fhow-do-i-fix-this-sqlite-java-lang-illegalstateexception-couldnt-read-row-0-c%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

            AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

            Алба-Юлія

            Захаров Федір Захарович