android blob pdf error not returning

Course Queries Syllabus Queries 3 years ago

4.55K 1 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 years ago


I have to store a some data fields and a pdf.I have created two classes ,the first is a DatabaseHandler which does all my basic database stuffs and to refer to a row of the database i have created a class myHelper which creates a record/row object having each data element that i require.The problem that i am facing is that i need to store a pdf inside the database.I have done " values.put(KEY_pdf, row.get_pdf()); " and it gives me an error " cannot resolve the method put() " and as obvious reasons i have declared the type as String.In my App ,What i want is that when i add some button in my activity after inputting the required sem,year,branch values from theuser,i need the pdf to be displayed that is the reason i have created the get() method for pdf,but this logic doesnt seem to work out or am i missing something.Urgent help.Moreover any improvements suggested are highly appreciable.

myHelper.java

package com.DataBaseHandler;

import java.sql.Blob;

/**
 *
 */

    public class myHelper {

        //private variables
        int _id;
        String _branch;
        int _year;
        int _sem;
        Blob _pdf;

        // Empty constructor
        public myHelper(){

        }
        // constructor
        public myHelper(int id, String _branch, int _year,int _sem,Blob _pdf){
            this._id = id;
            this._branch = _branch;
            this._year = _year;
            this._sem = _sem;
            this._pdf = _pdf;
        }
        // getting ID
        public int getID(){
            return this._id;
        }
        public void setID(int _id){
            _id =  this._id;
        }

        // getting branch
        public String get_branch(){
            return this._branch;
        }
        public void set_branch(String _branch){
            _branch = this._branch;
        }

        // setting year
        public int get_year(){
            return this._year;
        }
        public void set_year(int _year){
            _year = this._year;
        }

        // getting sem
        public int get_sem(){
            return this._sem;
        }
        public void set_sem(int _sem){
            _sem = this._sem;
        }

        // setting pdf
        public Blob get_pdf(){
          return this._pdf;
        }
        public void set_pdf(Blob _pdf){
            _pdf = this._pdf;
        }
}

DataBaseHandler.java
package com.DataBaseHandler;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum