android blob pdf error not returning

Course Queries Syllabus Queries 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 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.