Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9226569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:51:47+00:00 2026-06-18T04:51:47+00:00

I need to attach my SQLite Database to a Gmail email. I believe the

  • 0

I need to attach my SQLite Database to a Gmail email.

I believe the use of a Content Provider is necessary, but I cannot figure this out. Please help me understand this concept.

My db is located in the default directory "data/data/packagename/databases/"

My database name is TBProvider.

The class that extends ContentProvider is also named TBProvider.

TBProvider

public class TBProvider extends ContentProvider {

    static String PROVIDER_NAME =  
            "com.sas.aap.tbprovider";

    public static Uri CONTENT_URI = 
            Uri.parse("content://com.sas.aap.tbprovider");

    public static final String _ID = "_id";

    private static final int TB = 1;

    private static final UriMatcher uriMatcher;
        static{
            uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
            uriMatcher.addURI(PROVIDER_NAME, "*", TB);
        }


    public static final String DATABASE_NAME = "TBProvider";

    private SQLiteDatabase myTBProvider;



    private static class TBDBHelper extends SQLiteOpenHelper{

        TBDBHelper(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

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


    @Override
    public String getType(Uri uri) {
        switch (uriMatcher.match(uri)){
        case TB:
            return "vnd.android.cursor.dir/com.sas.aap.tbprovider ";        
        default:
            throw new IllegalArgumentException("Unsupported URI: " + uri);
        }
    }

    @Override
    public boolean onCreate() {
        Context context = getContext();
        TBDBHelper dbHelper = new TBDBHelper(context);
        myTBProvider = dbHelper.getWritableDatabase();
        return (myTBDatabase == null)? false:true;                  
    }
}

Email:

 public class Email extends Activity {

String personsEmail = "example@gmail.com";
EditText personsName;
String emailAdd, name;
Button sendEmail;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.email);     

    sendEmail = (Button) findViewById(R.id.bSEmail);        
    sendEmail.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            String subject = "Subject";

            Intent emailIntent = new Intent(Intent.ACTION_SEND);
            emailIntent.setType("vnd.android.cursor.dir/com.sas.aap.tbprovider ");      
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
            emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, 
                    TBProvider.CONTENT_URI);
            startActivity(emailIntent);

            }
        });
    }
}

Manifest:

      android:name="com.sas.aap.TBProvider"
      android:authorities="com.sas.aap.tbprovider"
      android:exported="true">

EDIT:

I am getting the following LogCat:

Writing exception to parcel
java.lang.IllegalArgumentException: Unsupported URI: content://com.sas.aap.tbprovider
at com.sas.aap.TBProvider.getType(TBProvider.java130)
at android.content.ContentProvider$Transport.getType(TBProvider.java:130)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:135)
at android.os.Binder.execTransact(Binder.java:367)
at dalvik.system.NativeStart.run(Native Method)

I need to finish this by the Super Bowl! Let me know if you need more info. I’ll be
Awake from now until I can get this solved. Please and Thank You!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:51:49+00:00Added an answer on June 18, 2026 at 4:51 am

    I FIGURED IT OUT!

    public ParcelFileDescriptor openFile(Uri uri, String mode)
            throws FileNotFoundException {
        File cacheDir = getContext().getDatabasePath(DATABASE_NAME);    
        return ParcelFileDescriptor.open(cacheDir, ParcelFileDescriptor.MODE_READ_ONLY);                    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pre-populated sqlite database and I need to attach this within my
I need to attach a file to the email Magento sends when a client
I need to attach an event handler to an object, and I placed this
This is the problem I am having. I need to attach some kind of
I need to attach a 'change' event to a dropdownlist. This dropdown list is
I am dealing with this problem. I need to attach files from my desktop
Here i need to attach one image with mail, the passing image like this
I need to attach a pdf I created in memory to an email. Attachments
I've a listview and i need to attach this listview table into FlowDocumentReader, can
I need to attach a submit listener to every form in an iframe but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.