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

  • Home
  • SEARCH
  • 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 7830353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:11:57+00:00 2026-06-02T11:11:57+00:00

i want to start camera with name from database and i have three database..

  • 0

i want to start camera with name from database and i have three database..
i have code like this:

public void startCamera() 
{
    long tim=System.currentTimeMillis();
     SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");
     String curTime =df.format(tim);
     System.out.println("Time : " + curTime);

    Cursor c = helper.getKomp(almagId2);
    Cursor ca = helper.getSat(almagId);
    Cursor cb = helper.getUlok(almagId1);
    if(c.moveToFirst()){
        fileName =c.getString(1)+"_"+"kanan"+"_"+System.currentTimeMillis()+ ".jpg";
    }else if(ca.moveToFirst()){
        fileName =ca.getString(1)+"_"+"kanan"+"_"+System.currentTimeMillis()+ ".jpg";
    }else if(cb.moveToFirst()){
        fileName =cb.getString(1)+"_"+"kanan"+"_"+System.currentTimeMillis()+ ".jpg";
    }

    _path=Environment.getExternalStorageDirectory().toString() + "/DCIM/Camera/";


    file = new File(_path, fileName);
    try {
    file.createNewFile();
    } catch (IOException e) {
    e.printStackTrace();
    }               
    System.out.println(file);
    Uri outputFileUri = Uri.fromFile(file);
    Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
    startActivityForResult(intent, IMAGE_CAPTURE);

    SQLiteDatabase db = helper.getWritableDatabase();
    if(c.moveToFirst()){
        db.execSQL("insert into image (kdstore,image1,tgl_buat) values ('"+c.getString(1)+"','"+file+"','"+curTime+"')");
    }else if(ca.moveToFirst()){
        db.execSQL("insert into image (kdstore,image1,tgl_buat) values ('"+ca.getString(1)+"','"+file+"','"+curTime+"')");
    }else if(cb.moveToFirst()){
        db.execSQL("insert into image (kdstore,image1,tgl_buat) values ('"+cb.getString(1)+"','"+file+"','"+curTime+"')");
    }
    db.close();


}

but when i want to call method startCamera i get error like this:

04-24 09:29:34.902: ERROR/AndroidRuntime(9411): FATAL EXCEPTION: main
04-24 09:29:34.902: ERROR/AndroidRuntime(9411): java.lang.NullPointerException
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at java.io.File.<init>(File.java:168)
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at com.sat.alfaloc.Camera.startCamera1(Camera.java:153)
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at com.sat.alfaloc.Camera.onClick(Camera.java:319)
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at android.view.View.performClick(View.java:2408)
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at android.view.View$PerformClick.run(View.java:8816)
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at android.os.Handler.handleCallback(Handler.java:587)
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at android.os.Handler.dispatchMessage(Handler.java:92)
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at android.os.Looper.loop(Looper.java:123)
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at java.lang.reflect.Method.invokeNative(Native Method)
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at java.lang.reflect.Method.invoke(Method.java:521)
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-24 09:29:34.902: ERROR/AndroidRuntime(9411):     at dalvik.system.NativeStart.main(Native Method)

how i can solved this??thank you for feed back 🙂

code above edited like this:

public void startCamera1() 
{
    long tim=System.currentTimeMillis();
     SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");
     String curTime =df.format(tim);
     System.out.println("Time : " + curTime);
     SQLiteDatabase db = helper.getWritableDatabase();

    Cursor c = helper.getKomp(almagId2);
    Cursor ca = helper.getSat(almagId);
    Cursor cb = helper.getUlok(almagId1);
    if(c.moveToFirst()){
        fileName =c.getString(1)+"_"+"kiri"+"_"+System.currentTimeMillis()+ ".jpg";
        _path=Environment.getExternalStorageDirectory().toString() + "/DCIM/Camera/";
        file = new File(_path, fileName);
        try {
        file.createNewFile();
        } catch (IOException e) {
        e.printStackTrace();
        }
        System.out.println(file);

        Uri outputFileUri = Uri.fromFile(file);
        Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
        startActivityForResult(intent, IMAGE_CAPTURE1);
        db.execSQL("insert into image (kdstore,image1,tgl_buat) values ('"+c.getString(1)+"','"+file+"','"+curTime+"')");
    }
    if(ca.moveToFirst()){
        fileName =ca.getString(1)+"_"+"kiri"+"_"+System.currentTimeMillis()+ ".jpg";
        file = new File(_path, fileName);
        try {
        file.createNewFile();
        } catch (IOException e) {
        e.printStackTrace();
        }
        System.out.println(file);

        Uri outputFileUri = Uri.fromFile(file);
        Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
        startActivityForResult(intent, IMAGE_CAPTURE1);
        db.execSQL("insert into image (kdstore,image1,tgl_buat) values ('"+ca.getString(1)+"','"+file+"','"+curTime+"')");
    }
    if(cb.moveToFirst()){
        fileName =cb.getString(1)+"_"+"kiri"+"_"+System.currentTimeMillis()+ ".jpg";
        file = new File(_path, fileName);
        try {
        file.createNewFile();
        } catch (IOException e) {
        e.printStackTrace();
        }
        System.out.println(file);

        Uri outputFileUri = Uri.fromFile(file);
        Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
        startActivityForResult(intent, IMAGE_CAPTURE1);
        db.execSQL("insert into image (kdstore,image1,tgl_buat) values ('"+cb.getString(1)+"','"+file+"','"+curTime+"')");
    }

    db.close();

}

this is no error but activity call doesn’t work..how solve it??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-02T11:11:59+00:00Added an answer on June 2, 2026 at 11:11 am

    The exception says that one of the arguments to the File constructor is null. It can’t be path_ because that would have led to a previous exception. It must be filename_. Your three-way if-else allows for the possibility that none of the branches will be true, and if none were, then filename_ would be null — so that must be what’s happening. Can you have a default filename if none of the conditions are true — i.e., can you add an else without an if, at the end of the chain?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation like this: start(); <Some code> end(); I want start() function
I want to start nutch from Java. How can I start cygwin from a
Upon starting my Android app, I want to auto start the native camera (can
I want to play the audio that was received from IP Camera. The format
I want to be able to (live) stream the frames/video FROM the iPhone camera
I want to start the camera and click a photo and store it in
I want to make a camera application in which i want to start front
I am using the following code to start the default Camera.Image is getting saved
I want to capture a frame buffer from a camera surface preview and send
I want to start camera activity in my android app and I know how

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.