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 8271073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:45:13+00:00 2026-06-08T06:45:13+00:00

I am developing an application to display records count of shape file in android.

  • 0

I am developing an application to display records count of shape file in android. But it giving null pointer exception due to following errors

07-23 15:16:32.598: W/dalvikvm(2844): threadid=1: thread exiting with uncaught exception (group=0x4001d800)

07-23 15:16:32.677: E/AndroidRuntime(2844): FATAL EXCEPTION: main

07-23 15:16:32.677: E/AndroidRuntime(2844): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.android.skeletonapp/com.example.android.skeletonapp.SkeletonActivity}: java.lang.InstantiationException: com.example.android.skeletonapp.SkeletonActivity

07-23 15:16:32.677: E/AndroidRuntime(2844):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)

07-23 15:16:32.677: E/AndroidRuntime(2844):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)

07-23 15:16:32.677: E/AndroidRuntime(2844):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)

07-23 15:16:32.677: E/AndroidRuntime(2844):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)

07-23 15:16:32.677: E/AndroidRuntime(2844):     at android.os.Handler.dispatchMessage(Handler.java:99)

07-23 15:16:32.677: E/AndroidRuntime(2844):     at android.os.Looper.loop(Looper.java:123)

07-23 15:16:32.677: E/AndroidRuntime(2844):     at android.app.ActivityThread.main(ActivityThread.java:4627)

07-23 15:16:32.677: E/AndroidRuntime(2844):     at java.lang.reflect.Method.invokeNative(Native Method)

07-23 15:16:32.677: E/AndroidRuntime(2844):     at java.lang.reflect.Method.invoke(Method.java:521)

07-23 15:16:32.677: E/AndroidRuntime(2844):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)

07-23 15:16:32.677: E/AndroidRuntime(2844):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-23 15:16:32.677: E/AndroidRuntime(2844):     at dalvik.system.NativeStart.main(Native Method)

07-23 15:16:32.677: E/AndroidRuntime(2844): Caused by: java.lang.InstantiationException: com.example.android.skeletonapp.SkeletonActivity

07-23 15:16:32.677: E/AndroidRuntime(2844):     at java.lang.Class.newInstanceImpl(Native Method)



07-23 15:16:32.677: E/AndroidRuntime(2844):     at java.lang.Class.newInstance(Class.java:1429)



07-23 15:16:32.677: E/AndroidRuntime(2844):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)



07-23 15:16:32.677: E/AndroidRuntime(2844):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)

07-23 15:16:32.677: E/AndroidRuntime(2844):     ... 11 more

And SkeletonActivity.java is

public class SkeletonActivity extends Activity {

    static final private int BACK_ID = Menu.FIRST;

    static final private int CLEAR_ID = Menu.FIRST + 1;

     private static String SHP_PATH =  Environment.getDataDirectory().getAbsolutePath() + "/data/com.shapes/places";

     private static String SHP_NAME = "popplaces.shp";

    private EditText mEditor;

   private final Context myContext;

    public SkeletonActivity(Context context) {
        this.myContext=context;
    }

    /** Called with the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        int recordCount = 0;

        // Inflate our UI from its XML layout description.

        setContentView(R.layout.skeleton_activity);


        // Find the text editor view inside the layout, because we

        // want to do various programmatic things with it.

        mEditor = (EditText) findViewById(R.id.editor);


        // Hook up button presses to the appropriate event handler.

        ((Button) findViewById(R.id.back)).setOnClickListener(mBackListener);

        ((Button) findViewById(R.id.clear)).setOnClickListener(mClearListener);

        mEditor.setText(getText(R.string.main_label));
        try {
            //File path = Environment.getExternalStoragePublicDirectory(
               //     Environment.DIRECTORY_PICTURES);
             //path = Environment.getDataDirectory().getAbsolutePath();
            //path.mkdirs();
            //shpFile = path.getPath().toString();
            copyFromZipFile();
             String shpFile = Environment.getDataDirectory().getAbsolutePath()+"/data/com.shapes/places/popplaces.shp";
            ShapeReader shR = new ShapeReader(shpFile, true);
                recordCount = shR.getCount(0);

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        mEditor.setText("Record Count == " + recordCount);
    }

    /**
     * Called when the activity is about to start interacting with the user.
     */
    @Override
    protected void onResume() {
        super.onResume();
    }

    /**
     * Called when your activity's options menu needs to be created.
     */
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);

        // We are going to create two menus. Note that we assign them
        // unique integer IDs, labels from our string resources, and
        // given them shortcuts.
        menu.add(0, BACK_ID, 0, R.string.back).setShortcut('0', 'b');
        menu.add(0, CLEAR_ID, 0, R.string.clear).setShortcut('1', 'c');

        return true;
    }

    /**
     * Called right before your activity's option menu is displayed.
     */
    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);

        // Before showing the menu, we need to decide whether the clear
        // item is enabled depending on whether there is text to clear.
        menu.findItem(CLEAR_ID).setVisible(mEditor.getText().length() > 0);

        return true;
    }

    /**
     * Called when a menu item is selected.
     */
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case BACK_ID:
            finish();
            return true;
        case CLEAR_ID:
            mEditor.setText("");
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    /**
     * A call-back for when the user presses the back button.
     */
    OnClickListener mBackListener = new OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    };

    /**
     * A call-back for when the user presses the clear button.
     */
    OnClickListener mClearListener = new OnClickListener() {
        public void onClick(View v) {
            mEditor.setText("");
        }
    };

   public void copyFromZipFile() throws IOException{ 

         InputStream is = myContext.getResources().openRawResource(R.raw.shape);

             // Path to the just created empty db 

             File outFile = new File(SHP_PATH ,SHP_NAME); 

              //Open the empty db as the output stream 

             OutputStream myOutput = new FileOutputStream(outFile.getAbsolutePath()); 

             ZipInputStream zis = new ZipInputStream(new BufferedInputStream(is)); 

              try { 

                  ZipEntry ze =  null; 

                  while ((ze = zis.getNextEntry()) != null) { 

                      ByteArrayOutputStream baos = new ByteArrayOutputStream(); 

                      byte[] buffer = new byte[24 * 1024]; 

                      int count; 

                      while ((count = zis.read(buffer)) != -1) { 

                          baos.write(buffer, 0, count); 

                          //Log.d("", buffer.toString()); 

                          baos.writeTo(myOutput); 

                          baos.reset();

                      } 
                      baos.writeTo(myOutput); 


                  } 
              } 
              catch (IOException e) {}

                  zis.close(); 

                  myOutput.flush(); 

                  myOutput.close(); 

                  is.close(); 

            }
}

And Manifest.xml is

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.skeletonapp">


    <application android:label="@string/skeleton_app">


        <activity android:name="SkeletonActivity">


            <intent-filter>

                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>

    </application>

</manifest>

Please help me to resolve this problem.
Thanks.

  • 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-08T06:45:15+00:00Added an answer on June 8, 2026 at 6:45 am

    The problem is your main intent (SkeletonActivity) has only 1 constructor, which android have no idea what todo. Start this activity via another or remove the constructor SkeletonActivity(Context context)

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

Sidebar

Related Questions

I am developing an application in android 2.1 and I want to display the
I'm interested in developing an android application that will display a globe of some
I would like to display Arabic text in my Android application. I am developing
I'm developing an application which make use of display lists offered by OpenGL. My
i am developing one application with map view i need display the weather depends
I'm developing one application for iphone using phone gap.I that I need to display
I am developing an iPhone application and I use HTML to display formatted text.
I'm developing a simple web application where in I need to display number a
I am developing a task manager application.. In that app, I display to the
I'm developing an application to display a gallery of UIImages by using a UIScrollView

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.