I developed a theme for my client. Theme have predefined posts, pages and sliders etc. when some one activate the theme, theme does the following steps on theme activation action hook. 1:- Empty the current WordPress database to avoid any duplicate data entry issue. 2:- Inserts predefined data in the WordPress core tables and creates some other required custom tables with data. Everything is working fine accept one issue and that is my theme removes all the previous data in the database. so that client lost his all previous data. i need any idea or help to tackle this issue. User just want to add new theme using theme zip file and all the posts and pages each and everything should be done automatically. Any help or idea will be highly appreciated.
Never change content without the user's specific manual request, and never ever delete anything from the DB that you haven't created.
So the only question left is how to create you sample content. The cleanest way is to provide an exported sample that can be imported into WP. The only problem with this approach is that it requires the installation of the wordpress importer plugin. The other possible approach is to write a code that will generate the sample content, but this also needs to be triggered by a manual action by the user.
If your user is not very bright (as most users are ;) ) you can show a short message about the existence of the option to import/generate a sample after theme's activation.